creating graph with multiple axis

조회 수: 2 (최근 30일)
Satyam Singh
Satyam Singh 2020년 7월 22일
답변: Pratheek Punchathody 2020년 9월 11일
I am trying to create a graph with 2 x axis and 2 y axis. I got a code which is working fine but there is an issue. it is not able to relate both the x axis.
So this the graph I am getting using the code below and the excel sheet attached here-
x1 = cell2mat (Nickel(:,3));
y1 = cell2mat(Nickel(:,1));
line(x1,y1,'Color','r')
ax1 = gca; % current axess
ax1.XColor = 'r';
ax1.YColor = 'r';
ax1_pos = ax1.Position; % position of first axes
ax2 = axes('Position',ax1_pos,...
'XAxisLocation','top',...
'YAxisLocation','right',...
'Color','none');
x2 = cell2mat(Nickel(:,4));
y2 = cell2mat(Nickel(:,2));
line(x2,y2,'Parent',ax2,'Color','b')
the problem that I am having is both the x axis are not related which means the red curve should be formed according to x1,x2 and y1. If you see the image below for reference just look at the peak number 6 of blue colored curve it is coming after 20 in fractions but in above graph it is before 20. So this the problem that I am not able to figure out. Please help me.
  댓글 수: 1
Sugar Daddy
Sugar Daddy 2020년 7월 22일
maybe because it is semilogx

댓글을 달려면 로그인하십시오.

답변 (1개)

Pratheek Punchathody
Pratheek Punchathody 2020년 9월 11일
Hi Satyam
plotxx is one of the several submissions in MATLAB File Exchange on MATLAB Central which is a forum for our product users to interact, exchange information and knowledge, without MathWorks' involvement. Feel free to contact the author of this submission directly for specific questions about the implementation"

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by