Editing the starting points of different lines in a graph
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello everyone, sorry for bothering you with a rookie question again. Suppose I do have a graph in which there are lines with different starting x-values so they start from different points along x-axis. Is there possibly a way to somehow rescale the x-axis, or to modify it in a manner such that the lines start from the same point along the x-axis; as if the x1 and x2 vectors in the code below had the same first value? Or would you think that, if the graph stayed like that, this would decrease the chances that my paper would be accepted by a journal, regardless of the quartile?
Thanks in advance!
x1 = [1, 2 ,3, 4, 5];
y1 = [5, 3, 2.8, 1.7, 1.2];
y2 = [6.5, 4.7, 3.5, 1.9, 1.3];
x2 = [2.1, 3.6, 3.8, 4, 5];
y3 = [6, 5.6, 3.1, 2.9, 1.7];
y4 = [5, 4.1, 3.8, 2, 1.5];
y5 = [5, 4, 3, 1.8, 1.4];
plot(x1,y1,x1,y2,'color', 'g'); %Model 1
hold on
plot(x2,y3,x2,y4,x2,y5,'color', 'b'); %Model 2
hold off
grid minor
xlabel('x values')
ylabel('y values')
title('figure 1')
댓글 수: 3
채택된 답변
Manikanta Aditya
2024년 7월 9일
To make the lines start from the same point along the x-axis, you could subtract the minimum value of each x-vector from all its elements. This would effectively “shift” your data so that each line starts from x=0.
Here is the modified code:
x1 = [1, 2 ,3, 4, 5];
y1 = [5, 3, 2.8, 1.7, 1.2];
y2 = [6.5, 4.7, 3.5, 1.9, 1.3];
x2 = [2.1, 3.6, 3.8, 4, 5];
y3 = [6, 5.6, 3.1, 2.9, 1.7];
y4 = [5, 4.1, 3.8, 2, 1.5];
y5 = [5, 4, 3, 1.8, 1.4];
% Shift x values
x1 = x1 - min(x1);
x2 = x2 - min(x2);
plot(x1,y1,x1,y2,'color', 'g'); %Model 1
hold on
plot(x2,y3,x2,y4,x2,y5,'color', 'b'); %Model 2
hold off
grid minor
xlabel('Shifted x values')
ylabel('y values')
title('figure 1')
As for your question about journal acceptance, it’s hard to say definitively as it can depend on the specific journal and the context of your research. However, clarity and accuracy in presenting your data are always important. If the original x-values have specific meanings or implications in your study, shifting them might lead to confusion.
I hope this helps!
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!