Gridlines do not show in xregion/yregion when exporting to pdf

7 visualizaciones (últimos 30 días)
ET
ET el 29 de Feb. de 2024
Comentada: ET el 14 de Mzo. de 2024
I have a plot showing a shaded region using the xregion command. The plot has grid lines showing and on the screen everything looks as it should. However, if I export this figure to a pdf (vector graphics), then the gridlines within the xregion area disappear.
I don't want to revert to using raster graphics for these plots -- the vector graphics are both smaller and look way better in my documents.
I could brute force this by manually drawing in all the gridlines and putting them on top, but this defeats the point of having a gridlines feature in the plots.
Is there a way to change a property in either xregion or gridlines to allow them to be seen in vector graphics output?
  1 comentario
Mike Croucher
Mike Croucher el 1 de Mzo. de 2024
Could you supply some code that reproduces the kind of plot you mean along with the faulty pdf please?

Iniciar sesión para comentar.

Respuesta aceptada

Umang Pandey
Umang Pandey el 14 de Mzo. de 2024
Hi,
From what I understand, you are trying to export your plot having a 1-D filled region to a PDF with vector graphics, however, in the process, the grid lines in the shaded region disappear.
I tried doing the same for an example from the xregion documentation page and was able to export my plot to a PDF with vector graphics. You can try referring to the following code and retry with your code:
% An example from xregion documentation page
x = -10:0.25:10;
y = x.^2;
plot(x,y);
xregion(-5,5);
% Making the grids appear on the plot
grid;
ax = gca;
% Exporting the plot as vector pdf
exportgraphics(ax,'1.pdf','ContentType','vector');
Hope this helps!
Best,
Umang
  1 comentario
ET
ET el 14 de Mzo. de 2024
Thanks, this does indeed work. In my original case I was using export_fig (v3.05) and the 'painters' renderer. I think it was the issue was that doing it this way, the transparency (facealpa) of graphical objects don't work and hence the gridlines disappeared. I was able to use the exportgraphics and it did work correctly.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Labels and Annotations en Help Center y File Exchange.

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by