问题
I have a very basic custom boxplot function:
function myboxplot(LPercentile, Median, RPercentile, Height, LineWidth, BoxHeight, MarkerColour, MarkerSize)
hold on
plot([LPercentile, RPercentile], [Height, Height], 'linewidth', LineWidth, 'color', 'k', 'linestyle', '-');
plot([LPercentile, LPercentile], [Height - BoxHeight/2, Height + BoxHeight/2], 'linewidth', LineWidth, 'color', 'k', 'linestyle', '-');
plot([RPercentile, RPercentile], [Height - BoxHeight/2, Height + BoxHeight/2], 'linewidth', LineWidth, 'color', 'k', 'linestyle', '-');
plot(Median, Height, 'marker', 'o', 'markersize', MarkerSize, 'markeredgecolor', 'k', 'markerfacecolor', MarkerColour);
hold off
end
When I use it as intended,
>> myboxplot(1,2,3,1,3,1,'g',20); hold on
>> myboxplot(2,3,5,3,3,1,'r',20); hold off
>> axis([0,6,0,4]);
it produces the expected result within my octave session:
But when I attempt to save to a file:
>> saveas(gcf,'out.pdf','pdf');
it fails miserably:
This happens regardless of output format (at least between pdf and png).
Is this a bug? Is there a workaround to make the lines visible?
(Note: I have also tried this code in matlab, and matlab saves the file as intended)
(using: GNU Octave Version: 4.0.3 GNU Octave License: GNU General Public License Operating System: Linux 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64 )
UPDATE: Octave 4.0.3 on windows produces the right output, so this is definitely a "bug" bug on linux. I will be submitting a bug on the octave tracker, but if anyone knows of any workarounds in the meantime I would be very grateful.
回答1:
This was indeed a genuine bug relating to one of the libraries octave uses to convert openGL graphics to postscript, rather than the octave base itself, as per the octave bug submission (bug #49225).
From the now closed bug report:
"This bug has been fixed in the latest version of gl2ps (1.3.9), but linux mint 17.3 ships with gl2ps 1.3.8. On linux, the workaround is to compile your own version of gl2ps."
I can confirm that installing libgl2ps1 (1.3.9-4) and libgl2ps-dev (1.3.9-4) and recompiling octave resolved this bug.
来源:https://stackoverflow.com/questions/39746234/octave-failing-to-include-parts-of-a-plot-when-saved-to-file