missing parts of a figure when converting to pdf

7 visualizzazioni (ultimi 30 giorni)
When I use exportgraphics (or print) to convert a matlab .fig file to a .pdf file, the markers near the yaxes missing.
The .fig looks like this
And the .pdf produced looks like this
The following are the code producing the .fig
f1 = figure;
f1.Position = [400, 300, 650, 450];
yyaxis left
f1_p1 = plot(ana_nl_rng, ana_w1_dl_vec, "--", "LineWidth", 1.1, "Color", "#0072BD");
hold on
f1_p2 = plot(sim_nl_rng, sim_w1_dl_vec, "x", "MarkerSize", 7.0, "LineWidth", 0.8, "Color", "#0072BD");
f1_p3 = plot(ana_ns_rng, ana_w1_ds_vec, "-.", "LineWidth", 1.1, "Color", "#D95319");
f1_p4 = plot(sim_ns_rng, sim_w1_ds_vec, "o", "MarkerSize", 7.0, "LineWidth", 0.8, "Color", "#D95319");
ylim([0, 30]);
set(gca,'YColor','k');
ylabel("$D^{(\phi)}$", "Interpreter", "latex", "FontSize", 14, "Rotation", 0, ...
'Units', 'normalized', 'Position', [-0.08, 0.53, 0.5]);
yyaxis right
f1_p5 = plot(ana_nl_rng, ana_nl_rng .* ana_w1_dl_vec + ana_ns_rng .* ana_w1_ds_vec, "-", "LineWidth", 1.1, ...
"Color", "#EDB120");
f1_p6 = plot(sim_nl_rng, sim_nl_rng .* sim_w1_dl_vec + sim_ns_rng .* sim_w1_ds_vec, "+", "MarkerSize", 7.0, ...
"LineWidth", 0.8, "Color", "#EDB120");
set(gca,'YColor','k');
ylabel("$\hat{D}$", "Interpreter", "latex", "FontSize", 14, "Rotation", 0, ...
'Units', 'normalized', 'Position', [1.09, 0.6, 0.5]);
ylim([120, 200]);
yticks(120:20:200);
xlim([5, 100]);
xticks([5, 10:10:100]);
xlabel("$n^{(LB)}$", "Interpreter", "latex", "FontSize", 15);
set(gca,'XTickLabel', get(gca,'XTickLabel'), 'FontSize', 14);
f1_ax1 = axes("Position", get(gca,"Position"), "Visible", 'off');
legend(f1_ax1, [f1_p1, f1_p2], ["Analysis", "Simulation"], "FontSize", 12);
f1_ax2 = axes("Position", get(gca,"Position"), "Visible", "off");
legend(f1_ax2, [f1_p3, f1_p4], ["Analysis", "Simulation"], "FontSize", 12);
f1_ax3 = axes("Position", get(gca,"Position"), "Visible","off");
legend(f1_ax3, [f1_p5, f1_p6], ["Analysis", "Simulation"], "FontSize", 12);
I added some arrows and textboxes manually afterwards, and I used the exportgraphics function to produce the .pdf
exportgraphics(f1, "./pdfs/dr_vs_n_fix_w_1.pdf")
Can anyone help me figure out what's the problem? Thank you!
  2 Commenti
Jan
Jan il 30 Lug 2022
Modificato: Jan il 31 Lug 2022
What happens, if you create the axes with an disabled clipping?
axes('Clipping', 'off')
@Jie Zhang: Please use flags to inform admins and editors about inappropriate contributions, e.g. rudeness or off-topic messages. Thanks! I've posted this comment as an answer also, such that it can be marked as a solution.
Walter Roberson
Walter Roberson il 30 Lug 2022
You could experiment with https://www.mathworks.com/help/matlab/ref/matlab.graphics.axis.axes-properties.html#budumk7_sep_shared-Layer setting the axes 'Layer' property to 'bottom' . It should be 'bottom' by default, but it just might make a difference, maybe.
You could also use xlim and ylim to make the axes slightly bigger so that the end points are inside the drawing area.

Accedi per commentare.

Risposta accettata

Jan
Jan il 31 Lug 2022
Copied from my suggestion in the comments:
Disable the clipping of the axes object:
axes('Clipping', 'off')

Più risposte (0)

Categorie

Scopri di più su Printing and Saving in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by