显示 更早的评论
how can i solve the problem of this two images automatically without having to fix the axes range for each plot (i have millions of these plots)?
(problem: axis shoud be for x[0 18]) and for y[-6 6]
(problem: the minimum x and minimum y should be bigger)
thank you so much.
采纳的回答
Matt Fig
2012-11-15
You can set the axes limits to be a certain percent of the data or fixed values, depending on what you want.
x = -pi:.001:pi;
y = sin(x).*x.^2;
plot(x,y)
axis([-5 5 -6 6]) % Use this to set the limits as needed
9 个评论
here in your code you are fixing values right?
how can i set the axes limits to be a certain percent of the data, as you suggested?
thank you very much.
There are several things you could do. One would be to add a certain percent to the endpoints. Another is to add a certain percent to the range. I show the second option here:
x = pi:.001:2*pi;
y = sin(x).*x.^2 + 1;
plot(x,y)
mnx = min(x);
mxx = max(x);
mny = min(y);
mxy = max(y);
dx = mxx-mnx;
dy = mxy-mny;
axis([mnx - .1*dx,...
mxx + .1*dx,...
mny - .1*dy,...
mxy + .1*dy])
i see... but following your advices, this code shouldn't work? :
grid on;
axis([(min(xxK)*0.120),...
(max(xxK)*0.120),...
(min(zzK)*0.120),...
(max(zzK)*0.120),...
(min(yyK)*0.120),...
(max(yyK)*0.120)])
Did you try it? How could I tell if that would work when you have not defined xxK, yyK, zzK etc.? Notice that my example was complete enough for you to copy and paste to examine the results....
yes, i tried yours and in fact is working perfectly. but i was trying a smaller code. if xxK, yyK, zzK are defined in the workspace isn't it enough? thank you so much.
"if xxK, yyK, zzK are defined in the workspace isn't it enough?"
Enough for what? You will get some results, assuming those are real numeric variables, but I still cannot tell if they are the results you want. Only you can tell, because only you can see the data and the results.
Good luck!
ok i understand. but just tell me this last question: when i use your code the axes of the plot produced are not numerated from the beggining? can i fix this?
(in your plot it is almost invisible but for me, as i am working with big numbers the plot shows a big empty space in the axes)
thank you so much.
In that case, something like this might be preferable:
x = pi:.001:2*pi;
y = sin(x).*x.^2 + 1;
plot(x,y)
xt = get(gca,'xtick');
dx = xt(2)-xt(1);
yt = get(gca,'ytick');
dy = yt(2) - yt(1);
pause(1)
axis([xt(1) - dx,...
xt(end) + dx,...
yt(1) - dy,...
yt(end) + dy])
Part of the problem is that we could go on forever trying to make your plot look just like you want it to look. I have tried to provide you with some tools to think about, play with, and apply to your particular data.
your code works with my data for 2D but when i work in 3D it doesn't. i will send you my code and excel file by email. if you don't mind to take a few minutes to see the problem, i would be very grateful.
if you can't, thank you very much as well for ALL your help and kindness!
thank you so much.
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Graphics Performance 的更多信息
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
