plot with grouping variables

조회 수: 8 (최근 30일)
Melanie
Melanie 2013년 3월 6일
댓글: Majid Hamzavi 2020년 10월 5일
Hi there! I’m a beginner in working with matlab but maybe someone knows how to deal with this.
I want to plot a few selected graphs out of a matrix. I have for about 30 various doses (first column) 10 times resp (second column) with associated concentration (third column).
Therefore the concentration should be plotted semilogarithmic against time and the graphs should be grouped by the various doses. For the plot I want to select only a few graphs say dose 1 and 2 and not all the available ones. Using the command ‘gscatter' I can group my concentrations by dose but I need to plot a real graph rather than a scatter.

채택된 답변

Tom Lane
Tom Lane 2013년 3월 7일
I'm not clear what you mean by a "real" graph. If you want the points connected by lines, you can specify a linestyle after using gscatter:
x = [1;2;5;9];
xx = [x;x;x];
yy = [15-x; 20-2*x; 12-.5*x];
g = [1 1 1 1 2 2 2 2 3 3 3 3];
h = gscatter(xx,yy,g)
set(h,'LineStyle','-')
  댓글 수: 1
Majid Hamzavi
Majid Hamzavi 2020년 10월 5일
Using the same strategy for 'set', it gives me the error as:
Unable to use a value of type matlab.graphics.chart.primitive.Line as an index.

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

추가 답변 (1개)

Melanie
Melanie 2013년 3월 7일
Thanks Tom, this is perfectly working!!
But how can I change my y-axis into semilogarithmic? For the scatter I use the command
h=gscatter(ds.PT,ds.conc,ds.dose)
How can I specify for which dose (say 1 and 2) I want to plot the graphs? If I use the command above I have all graphs in one figure
  댓글 수: 2
Tom Lane
Tom Lane 2013년 3월 7일
set(gca,'YScale','log') % to change y axis to log scale
For the other, you probably have to loop:
for j=1:3
subplot(2,2,j);
t = (g==j);
plot(xx(t),yy(t));
title(sprintf('group %d',j));
end
Melanie
Melanie 2013년 3월 8일
Many thanks! Now it's working!

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

카테고리

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