partypeter
partypeter

Reputation: 112

How to print/export a scatter plot with the a specific linewidth?

I am trying to export a scatter plot that shows the data points as small crosses ('x'). When I specify the linewidth of the crosses in the code it changes the linewidth in the displayed figure, as it should be. But when I export the figure with 'print' the linewidth is always this, I assume set to 1.

I printed the figure as PNG, EPS and JPEG and the result is the same.

Example code:

x=rand(5,1);

y=rand(5,1);

scatter(x,y,150,'x','linewidth',20)

print(['Test.png'],'-dpng','-r600' )

Edit: I am using MATLAB 2018b.

Upvotes: 0

Views: 143

Answers (1)

liorr
liorr

Reputation: 800

I can reproduce this bug in 2018b. This screenshot of my desktop shows the figure (left), exporting the figure using Matlab's UI (middle) and exporting figure using Matlab's print(). The line width is clearly different in the latter.

enter image description here

While I cannot tell you why this happens, this still can be resolved using the excellent export_fig function from this package. Here is the output using export_fig test_ef.png:

enter image description here

Upvotes: 2

Related Questions