problem with errorbars and export_fig

2 ビュー (過去 30 日間)
Rhys
Rhys 2013 年 6 月 16 日
Hi everybody, I have come across a strange problem while using export_fig(). It does not seem to export errorbars
x=1:10;
y=x.^2-2*rand(size(x));
err=abs(x.^2-y);
errorbar(x,y,err,'r*')
legend('data'
export_fig(gca,'testing.jpg')
hold on
plot(x,y,'--')
export_fig(gca,'testing2.jpg')
When I try to run this code (or anything with errorbars) export_fig() leaves the errorbars out. In the example code testing.jpg appears to me as a blank set of axis. I noticed that if I use plot() to plot the markers onto the axes export_fig works just fine. Is there something extra I need to add into export _fig to make it work with errorbars?
Cheers
Rhys

採用された回答

Oliver Woodford
Oliver Woodford 2013 年 6 月 19 日
Export_fig exports error bars just fine. Try:
x=1:10;
y=x.^2-2*rand(size(x));
err=abs(x.^2-y);
errorbar(x,y,err,'r*')
export_fig(gcf,'testing.jpg')
hold on
plot(x,y,'--')
export_fig(gcf,'testing2.jpg')
  2 件のコメント
the cyclist
the cyclist 2013 年 6 月 19 日
Rhys, notice the tiny but critical difference in the code. Oliver is exporting the current figure (gcf) where you were trying to export the current axes (gca).
Rhys
Rhys 2013 年 6 月 19 日
Thank you Oliver and cyclist. export_fig() is now doing exactly what I want with it! Thanks for your help! It will undoubtedly will be a great tool as a pursuit physics!
Cheers,
Rhys!

サインインしてコメントする。

その他の回答 (1 件)

the cyclist
the cyclist 2013 年 6 月 16 日
Try adding a drawnow command before the first export_fig. Does it work?
  1 件のコメント
Rhys
Rhys 2013 年 6 月 16 日
It does not change.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeErrorbars についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by