Two graphs in one plot with own RGB hex or decimal code
조회 수: 11 (최근 30일)
이전 댓글 표시
Hi, I would like to set my own RGB color to my graphs. I did it with single plots, this works, but I can't get it working with two graphs in one plot and own color codes. How? Here is my single plot code:
% figure(6);
plot(f,Yr,...
'LineWidth',1,...
'color', [0/255 177/255 175/255])
xlim([20e6 30e6])
%ylim([4 5])
grid on
title('Admittance Y_r')
xlabel('f[Hz]')
ylabel('Yr(f)')
And here is the plot I would like to set my own RGB color code as well, but doesn't matter how I change the syntax, it doesn't work on the same principle like in the single graph plot.
figure(7);
plot(f,Bn,'green',f,Gn,'black',...
'LineWidth',1)
xlim([20e6 30e6])
%ylim([4 5])
grid on
title('Conductance Gn and susceptance Bn')
xlabel('f[Hz]')
ylabel('Bn and Gn')
Can somebody help me please. I googled for so long, but all "solutions" failed. I'm using MATLAB R2017a with a student license.
best regards Jogibaer
댓글 수: 2
Adam
2017년 6월 13일
What exactly is wrong? When I run code similar to yours I get a green plot and a black plot, as expected. I don't have your exact data so I made some up, but that should be irrelevant.
답변 (1개)
Adam
2017년 6월 14일
You'd have to plot them in two instructions to do that, e.g.
plot( hAxes, x1, y1, 'color', [0 0.5 0] );
hold( hAxes, 'on' );
plot( hAxes, x2, y2, 'color', [0 0 0.5] );
댓글 수: 5
Adam
2017년 6월 15일
It is very useful to get used to graphic object handles in Matlab and it is more intuitive now that they are proper visible objects. Anything you want to change on a plot you can just do so via the handle that you keep hold of (likewise axes etc) and you can play around with settings to see what you want by using, for example
inspect( hAxes )
and changing settings on there as you please. Then you can put them in code when you are happy. Also just typing
hAxes
on the command line will show you all the properties that you can edit.
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
