*Note, image uplaod isn't working. It's the first image here: http://oneshisttwoshistgreenshistblueshist.blogspot.com
Eliminate backtrack in graph?
2 次查看(过去 30 天)
显示 更早的评论
Hi there! I've attached a figure below which graphs changes in flux by season. Problem: Matlab is currently drawing lines in between the beginning and end of my seasons, making the graphs look odd. Is there a simple way to keep it from doing this?
Thanks a bunch!
subplot(2,2,3)
plot(Fall(:,2),Fall(:,3))
title('Fall')
subplot(2,2,4)
plot(Wtr(:,2),Wtr(:,3))
title('Wtr')
subplot(2,2,1)
plot(Spr(:,2),Spr(:,3))
title('Spr')
subplot(2,2,2)
plot(Sum(:,2),Sum(:,3))
title('Sum')
3 个评论
Angus
2013-6-11
编辑:Angus
2013-6-11
It seems like it is plotting more than just a single data set for each plot, or the 'y' data domain is larger than the plotting window. Im not sure what is going on but what are the dimensions of Fall(:,2) and Fall(:,3)? What types are they? Ill see if I can find an example of this elsewhere.
Cheers, Angus
(You may want to avoid using variable names that are also built-in functions, such as sum, it may end up in confusing errors if you drop a capital)
采纳的回答
the cyclist
2013-6-11
编辑:the cyclist
2013-6-11
The default line style for plot() is the draw a line between each pair of points. If it is OK to not have any of those lines, then you could plot just the data points, for example
plot(Fall(:,2),Fall(:,3),'.')
However, if you want the lines except when it "backtracks", then probably need to split your data into separate series for plotting. You could do this by deftly inserting NaN into your vectors where the backtracking occurs. Here is a simple example of what I mean. Notice the difference between the two plots.
x1 = [1 2 3 1 2 3];
y1 = [1 2 3 3 4 5];
figure
plot(x1,y1,'-')
x2 = [1 2 3 nan 1 2 3];
y2 = [1 2 3 nan 3 4 5];
figure
plot(x2,y2,'-')
2 个评论
Angus
2013-6-12
Ahhh, repeated 'x' values, that is how that happens hey? Good to know, I hadn't thought of that. As you mentioned above about it being multiple data years you might want to consider plotting it so that they are separate lines with distinct colors. I imagine this would help keep track of which year you were looking at.
xF = Fall(1:100,2) % Whatever the full range is
xW = Wtr(1:100,2)
%etc.
subplot(2,2,3)
plot(xF,Fall(1:100,3),xF,Fall(101:200,3),xF,Fall(201:300,3))
%This will eliminate backtracks and give them distinct colors for each year
title('Fall')
subplot(2,2,4)
plot(xF,Wtr(1:100,3),xF,Wtr(101:200,3),xF,Wtr(201:300,3))
%The colors will match the ones used in the Fall plot
title('Wtr')
%etc.
Glad you got it figured out, have a good one.
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!