print figure to pdf - each plotted line gets split into smaller segments, leaving small gaps between them
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
DrB
am 20 Jan. 2016
Bearbeitet: DrB
am 23 Jan. 2016
Consider the following simple code:
clf
hold on
x = linspace(0,3*pi,600);
plot(x,sin(x),'k--','LineWidth',20)
plot(x,cos(x),'r-','LineWidth',20)
ylim([-1.2,1.2])
print('-dpdf','-r800','TestFig.pdf')
In the file 'TestFig.pdf' (highlighted by blue circles in attached image), it appears that the red and black line plots have been broken into smaller segments. You can see this e.g. at the top of the red peak (around x=2*pi), where there is a small white gap. You can also see this at various points along the dashed line (e.g. around x=pi); where one line segment stops and the next starts, the dash pattern is broken.
The number of data points in each line is 600. It appears this is being split up into line segments roughly 100 data points in length each. I wonder whether the print function is intentionally splitting the lines into smaller segments, and if so whether there is some way of stopping this happening so that each line is one uninterrupted vector object. Currently I am having to do this manually in Inkscape afterwards (where each segment is a different vector graphic object).
The choice of linewidth (20) and resolution ('-r800') is to exaggerate the effect. The problem still appears for other linewidths and resolutions. It also appears when printing to other vector graphic formats (e.g. .eps), although not for bitmaps (e.g. .png).
I've checked this on Matlab 2012 and 2014, on Ubuntu, Windows and OSX, all of which give the same behaviour.
0 Kommentare
Akzeptierte Antwort
Rebecca Krosnick
am 22 Jan. 2016
When I changed the number of points to 100 it seems the curves are no longer broken up into segments. I do not see those gaps. I also do not see the overlapping black dashes on the flat part of the curve. I however do still see the overlapping dashes at the very curvy parts of the curve, but I think that is unavoidable.
I also tried running your code in MATLAB R2014b, and with 600 points the gaps have disappeared, so you might want to try R2014b if you have access.
2 Kommentare
Walter Roberson
am 22 Jan. 2016
This is something that has changed a fair bit in R2014b, and has been tweaked since then.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Graphics Performance finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!