CVS yy-axis plot
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hello,
I have attached the simulation result and csv file but I want to plot these graphs in matlab after plotting the graps in matlab my Y-axis is missing. This is my code I need help please where i went wrong.
plotData = importdata('nmosesd.csv')
plotData.colheaders(1)
plotData.data(1)
figure(1)
clf
hold on
grid minor
hLine(1)=plot(plotData.data(:,1),plotData.data(:,2),'*-r','LineWidth',2)
hLine(2)=plot(plotData.data(:,3),plotData.data(:,4),'p-b','LineWidth',2)
hLine(3)=plot(plotData.data(:,5),plotData.data(:,6),'o-k','LineWidth',2)
hLine(4)=plot(plotData.data(:,7),plotData.data(:,8),'^-g','LineWidth',2)
title('Output Voltage at 10K\Omega')
set(gca,'FontSize',11);
xlabel('Time','FontSize',11,'FontWeight','bold')
ylabel('Voltage','FontSize',11,'FontWeight','bold')
legend([hLine(1) hLine(2) hLine(3) hLine(4)],'Input Power for Low Vth transistor','Current','Input Power for High Vth transistor', 'Input Power for Standard Vth transistor')
채택된 답변
Star Strider
2019년 5월 2일
1 개 추천
Try this:
plotData = importdata('nmosesd.csv')
plotData.colheaders(1)
plotData.data(1)
figure(1)
clf
hold on
grid minor
hLine(1)=plot(plotData.data(:,1),plotData.data(:,2),'*-r','LineWidth',2)
hLine(2)=plot(plotData.data(:,3),plotData.data(:,4),'p-b','LineWidth',2)
hLine(3)=plot(plotData.data(:,5),plotData.data(:,6),'o-k','LineWidth',2)
hLine(4)=plot(plotData.data(:,7),plotData.data(:,8),'^-g','LineWidth',2)
hold off
yyaxis right % Add Right Y-Axis
yt = get(gca, 'YTick'); % Get Default Y-Yick Values
newyt = linspace(min(yt), max(yt), 12); % Create New Right Y-Tick Values
newytl = linspace(-100, 1000, numel(newyt)); % Create New Right Y-Tick Labels
set(gca, 'YTick',newyt, 'YTickLabel',newytl); % Set New Right Y-Tick Labels
title('Output Voltage at 10K\Omega')
set(gca,'FontSize',11);
xlabel('Time','FontSize',11,'FontWeight','bold')
ylabel('Voltage','FontSize',11,'FontWeight','bold')
I do not have your data to work with. This works on my test plot.
댓글 수: 13
Thank you for yourr answer. but it was not working for me both x and y axis got blank and there is one error :
Undefined function or variable 'yyaxis'.
Error in nmos (line 13)
yyaxis right % Add Right Y-Axis
My matlab edition is R2015a: I also attached my csv file.
Star Strider
2019년 5월 2일
My pleasure.
The yyaxis function appeared first in R2016a.
To use plotyy, you would do something like this:
x = 1:10;
y1 = 2*exp(-0.4*x);
y2 = 2*exp(-0.5*x);
y3 = 2*exp(-0.6*x);
y4 = 2*exp(-0.7*x);
figure
[Ax,H1,H2] = plotyy(x, y1, x, y2);
hold on
plot(x, y3, x, y4)
hold off
yt = get(Ax(2), 'YTick'); % Get Default Y-Yick Values
newyt = linspace(min(yt), max(yt), 12); % Create New Right Y-Tick Values
newytl = linspace(-100, 1000, numel(newyt)); % Create New Right Y-Tick Labels
set(Ax(2), 'YTick',newyt, 'YTickLabel',newytl); % Set New Right Y-Tick Labels
I am not certain the plotyy would work with your code as you posted it, so I will let you adapt your data to this code.
Rai
2019년 5월 2일
The code which you write where I have to make changes? I try to make same changes in the exponential but still not geeting any success
Star Strider
2019년 5월 2일
Plot them as:
figure
[Ax,H1,H2] = plotyy(plotData.data(:,1),plotData.data(:,2), plotData.data(:,3),plotData.data(:,4));
hold on
plot(plotData.data(:,5),plotData.data(:,6), 'o-k', plotData.data(:,7),plotData.data(:,8),'^-g')
hold off
H1.LineStyle = '*-r';
H2.LineStyle = 'p-b';
hold off
yt = get(Ax(2), 'YTick'); % Get Default Y-Yick Values
newyt = linspace(min(yt), max(yt), 12); % Create New Right Y-Tick Values
newytl = linspace(-100, 1000, numel(newyt)); % Create New Right Y-Tick Labels
set(Ax(2), 'YTick',newyt, 'YTickLabel',newytl); % Set New Right Y-Tick Labels
That should work. (I cannot test it because I do not have your data.)
Rai
2019년 5월 3일
After I write your code still the YY-axis current label is missing and x-axis points are not correct. I also try to make legend but it genrate some error. I also attach my CSV data file please check

Star Strider
2019년 5월 3일
Try this:
[plotData,S] = xlsread('nmosesd.csv');
figure
[Ax,H1,H2] = plotyy(plotData(:,1),plotData(:,2), plotData(:,3),plotData(:,4));
hold on
plot(plotData(:,5),plotData(:,6), 'o-k', plotData(:,7),plotData(:,8),'^-g')
hold off
H1.LineStyle = '-.';
H2.LineStyle = '--';
hold off
ylabel(Ax(1), 'V(V)')
ylabel(Ax(2), 'I(mA)');
legend('Low Vth', 'Current', 'High Vth', 'Standard Vth') % Create Legend
ytr = get(Ax(2), 'YTick'); % Get Default Right Y-Yick Values
newytr = linspace(min(ytr), max(ytr), 12); % Create New Right Y-Tick Values
newytrl = linspace(-100, 1000, numel(newytr)); % Create New Right Y-Tick Labels
set(Ax(2), 'YTick',newytr, 'YTickLabel',newytrl); % Set New Right Y-Tick Labels
ytl = get(Ax(1), 'YTick'); % Get Default Left Y-Yick Values
newytl = linspace(min(ytl), max(ytl), 12); % Create New Left Y-Tick Values
newytll = round(newytl,1); % Create New Left Y-Tick Labels
set(Ax(1), 'YTick',newytl, 'YTickLabel',newytll); % Set New Left Y-Tick Labels
xt = get(gca, 'XTick');
set(gca, 'XTick',xt, 'XTickLabel',xt*1E+6)
xlabel('Time (ns)')
producing:

Thank you for help I am geeting the desired graph.. But there is one problem I have to add markes for the other two graphs but it will generate error when ever I try to do it. Also is there any way i make my graphs LineWidth more than this. I use some commands but it will generate errors. I want to my graphs look like this: Please tell me where is problem in code
[plotData,S] = xlsread('nmosesd.csv');
figure
[Ax,H1,H2] = plotyy(plotData(:,7),plotData(:,8), plotData(:,3),plotData(:,4));
hold on
grid minor
plot(plotData(:,5),plotData(:,6), 'o-k', plotData(:,1),plotData(:,2),'^-g')
hold off
H1.LineStyle = '-';
H2.LineStyle = '--';
hold off
ylabel(Ax(1), 'V(V)')
ylabel(Ax(2), 'I(mA)');
legend('Low Vth', 'Current', 'High Vth', 'Standard Vth') % Create Legend
ytr = get(Ax(2), 'YTick'); % Get Default Right Y-Yick Values
newytr = linspace(min(ytr), max(ytr), 12); % Create New Right Y-Tick Values
newytrl = linspace(-100, 1000, numel(newytr)); % Create New Right Y-Tick Labels
set(Ax(2), 'YTick',newytr, 'YTickLabel',newytrl); % Set New Right Y-Tick Labels
ytl = get(Ax(1), 'YTick'); % Get Default Left Y-Yick Values
newytl = linspace(min(ytl), max(ytl), 12); % Create New Left Y-Tick Values
newytll = round(newytl,1); % Create New Left Y-Tick Labels
set(Ax(1), 'YTick',newytl, 'YTickLabel',newytll); % Set New Left Y-Tick Labels
xt = get(gca, 'XTick');
set(gca, 'XTick',xt, 'XTickLabel',xt*1E+6)
xlabel('Time (ns)')

Star Strider
2019년 5월 3일
Those are the constraints of the plotyy function. The only way I can think of to add markers to the other plots, since plotyy only permits certain line styles, is to plot the marker specifically in another plot call. So if you want to add green upward-pointing tirangles to ‘Standard Vth’, use this:
plot(plotData(:,7),plotData(:,8),'^g')
That should work.
Rai
2019년 5월 3일
I try this but it was not working if I leave the markers it still okay but the line width is too samll. Is there any way I change the widths of all graphs.
Star Strider
2019년 5월 3일
That does not appear to ba an option with plotyy.
Rai
2019년 5월 3일
okay thank so much Strider for your help and time.
Star Strider
2019년 5월 3일
My pleasure.
Rai
2019년 5월 3일
I try to use 'bold' command to make my all three axis to be more visible but no success for me. Is it possible to it them bold? or not. I need help regarding bold command in the code where I have to do it
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Annotations에 대해 자세히 알아보기
참고 항목
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)
