Why does MATLAB export the .png with a graph besides the right y-axis?
17 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Tom Kristian Hoffmann
el 31 de Mzo. de 2023
Comentada: David Wilkinson
el 26 de Abr. de 2023
When opening the exported .png file I see that MATLAB has added or extended the graph beyond the right y-axis. I want to plot several shorter time series of a long temperature history and use xlimit to achieve my wanted time window. When exporting the figure as a svg or eps it is gone but then other information go missing.
How can I eliminate the 'extra' graph on the right side for my .png?
2 comentarios
Vinayak Choyyan
el 11 de Abr. de 2023
Hi Tom,
This is not an expected behaviour. Please share your code and data with us so that we can investigate the issue.
Alternatively, you can create a technical service request at http://www.mathworks.com/support/servicerequests/index.html and send us the above details over the request.
Respuestas (1)
David Wilkinson
el 22 de Abr. de 2023
Editada: David Wilkinson
el 22 de Abr. de 2023
Hello,
I just experienced a similar issue using R2023a.
Similar to yourself, I was plotting a figure with a left and right y-axis, using yyaxis left and yyaxis right.
The issue arose when I exported using exportgraphics.
There was a small part of the graph showing outside the main axes, past the right y-axis label.
To remedy this, I did the following:
- Set axis padding to be consistent for both the yyaxis left and yyaxis right plots (I used "axis tight")
- Set the x limit accordingly after the above line, for each plot
yyaxis left
plot(your_data)
axis tight
xlim([0 1])
yyaxis right
plot(your_other_data)
axis tight
xlim([-4 12])
exportgraphics(gcf,"test.png")
I hope this fixes your issue.
All the best,
David
Edit: Whilst I thought this fixed it, it appears having any xlim on a dual y-axis plot causes the issue...
3 comentarios
David Wilkinson
el 26 de Abr. de 2023
Interestingly, I am seeing the issue with just
exportgraphics(gcf,"test.png")
There doesn't seem to be an explainable pattern here...
David Wilkinson
el 26 de Abr. de 2023
This seems to be a recurrent issue. The linked forum states there's no practical workaround (without decreasing resolution).
Ver también
Categorías
Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!