필터 지우기
필터 지우기

missing parts of a figure when converting to pdf

조회 수: 8 (최근 30일)
Jie Zhang
Jie Zhang 2022년 7월 30일
편집: Jan 2022년 7월 31일
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
Jan
Jan 2022년 7월 30일
편집: Jan 2022년 7월 31일
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 2022년 7월 30일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2022년 7월 31일
Copied from my suggestion in the comments:
Disable the clipping of the axes object:
axes('Clipping', 'off')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by