How can I change the linewidth of my plot, without affecting the marker type and size?

6 views (last 30 days)
I am trying to make nice looking plots, and I know exactly how I want them. I want open squares for the data points, and the points to be connected by thicker lines than the default. This seems to be really hard to do, because as soon as I specify the line width, the squares turn into (very pixelated) circles with a thick line.
xvalues = [-4 0 -4];
yvalues = [4 2 0];
h = plot([xvalues,yvalues],'-s);
h.LineWidth = 2;
If I comment out the LineWidth, I get the squares as I want them, but the line too thin. If I include it the squares disappears.
I am also having trouble using the XTick-setting. I've added ...
ax = gca;
ax.XTick = [-4 -2 0 -2 -4];
... but nothing happens.
Would appreciate any help in resolving this. I'm using MATLAB R2016a.

Accepted Answer

KSSV
KSSV on 12 Apr 2016
xvalues = [-4 0 -4];
yvalues = [4 2 0];
h = plot([xvalues,yvalues],'-s','MarkerSize',2);
h.LineWidth = 10;
XTick = [-4 -2 0 -2 -4];
set(gca,'XTickLabel',XTick)

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!