Increase grid resolution when printing/saving eps

1 visualización (últimos 30 días)
Michael
Michael el 22 de Mayo de 2013
I am trying to save eps graphics for insertion into Latex documents. To do this I scale the figure using:
set(figure_handle, 'PaperPosition', [0 0 plot_width plot_height]);
The width and height I specify matches what I am going to be using in the document, so the fonts sizes I use in this matlab figure are the same when I insert them into the document at 100% scaling.
My problem is that when I use "set(figure_handle, 'PaperPosition',..." the grid resolution (turned on using 'grid on') decreases to a point where there are only a few dots between major tick points. Here is some example code:
h = figure
plot(rand(1,10),rand(1,10)) %Create the plot
grid on %Turn on the grid
set(h,'Units','inches') %Set the units
saveas(h,'nicegridres.eps','epsc') %Save the original figure with the nice resolution in the grid
set(h,'Paperposition',[0,0,2.75,1.8]) %Change the size of the figure for printing/saving
saveas(h,'badgridres.eps','epsc') %Save the new figure with the bad resolution in the grid
Don't mind the fact that the font sizes look too big. I have already taken care of that. It should be evident in the two output figures that the number of dots in the grid in the second saved figure are reduced. Basically what I am asking is, how can I increase the number of dots in the grid? Thanks!
FYI, I am using R2010a.

Respuesta aceptada

Michael
Michael el 22 de Mayo de 2013
I figured this out myself.
Download fixPSlinestyle.m from Matlab File exchange here. http://www.mathworks.com/matlabcentral/fileexchange/17928-fixpslinestyle
Around line 60 of this script is a line that controls the resolution of the dotted lines. Here is what it looks like:
dotLine = sprintf('/DO { [3 dpi2point mul 3 dpi2point mul] 0 setdash } bdef\n');
^ ^
| |
The two '3's you see in this line are the numbers that control the spacing of the dashed lines. Increasing the first one increases the length of the dashes, and increasing the the second increases the white space between the dashes. I am not certain about the specifics on these numbers, but you can play with their values until you get a result that looks good for your figure. Note that this will affect all the dotted lines in your figure, not just the grid.

Más respuestas (0)

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by