Remove all markers from line plot using second yaxis
10 ビュー (過去 30 日間)
古いコメントを表示
Hello everyone,
I think I have tried everything to fix this, but I am stumped. I am trying to plot 2 "line" plots over each other. The plot connected to the left yaxis is fine, but when I add the second axis two things go all wonky.
1) Markers and line style... no matter what I try, the markers on the 2nd yaxis plots stay. I have tried to change them using, '-', '.', and 'none'. I would like to have them all gone. No markers at all and have all of the line styles be the same.
2)The plot for the first yaxis moves to a weird place in the graph. This only happens everyone once in a while, usually when I try to change the appearance of the second yaxis.
Basically, I want to plot 2 groups of information over each other. I've even tried switch the data associated with each axis and the markers still show up. How do I set the markers to 'non' and the line style to '-'?
figure('Color','w','units','normalized','outerposition',[0 0 1 1])%Colors the figure white.
box off;
h = gca;
h.XAxis.LineWidth = 2;
h.YAxis(1).LineWidth = 2;
h.YAxis(1).FontWeight = 'bold';
h.XAxis.FontWeight = 'bold';
h.YAxis(1).Color = [0 0 0];
xlabel('Year','FontName','Times New Roman','fontweight','bold','FontSize',16)
ylabel('Snowfall accumulation (mm we)','FontName','Times New Roman','fontweight','bold','FontSize',16)
hold on;
plot(DecDate1,a1980,'LineWidth',1,'Color',[0 0 0]); hold on; %These are on the first axis.
plot(DecDate2,a1981,'LineWidth',1,'Color',[0 1 0]); hold on;
h = gca;
yyaxis right;
h.YAxis(2).LineWidth = 2;
h.YAxis(2).FontWeight = 'bold';
h.YAxis(2).Color = [.740 0 .749];
ylabel('Degrees (°C)','FontName','Times New Roman','fontweight','bold','FontSize',16)
hold on;
plot(Jan6hrLYdecdate,Jan1980,'LineWidth',1,'Color',[0.749 0 0.749]); hold on; %These go on the second axis
plot(Feb6hrLYdecdate,Feb1980,'LineWidth',1,'Color',[0.749 0 0.749]);
plot(Mar6hrLYdecdate,Mar1980,'LineWidth',1,'Color',[0.749 0 0.749]);
plot(Apr6hrLYdecdate,Apr1980,'LineWidth',1,'Color',[0.749 0 0.749]);
plot(May6hrLYdecdate,May1980,'LineWidth',1,'Color',[0.749 0 0.749]);
plot(Jun6hrLYdecdate,Jun1980,'LineWidth',1,'Color',[0.749 0 0.749]);
plot(Jul6hrLYdecdate,Jul1980,'LineWidth',1,'Color',[0.749 0 0.749]);
plot(Aug6hrLYdecdate,Aug1980,'LineWidth',1,'Color',[0.749 0 0.749]);
plot(Sept6hrLYdecdate,Sept1980,'LineWidth',1,'Color',[0.749 0 0.749]);
plot(Oct6hrLYdecdate,Oct1980,'LineWidth',1,'Color',[0.749 0 0.749]);
plot(Nov6hrLYdecdate,Nov1980,'LineWidth',1,'Color',[0.749 0 0.749]);
plot(Dec6hrLYdecdate,Dec1980,'LineWidth',1,'Color',[0.749 0 0.749]); hold on;
Using this code, this is what I get.
All of those markers and different line styles need to be simple and plain lines.
All decdate variables are simply the dates the samples were collected, listed as a decimal. "a1980" and "Jan1980", etc are the sample readings. There are several hundred samples per month and per year.
(Sorry about the colors. I just thought it would make it easier to distinguish the styles.)
0 件のコメント
回答 (2 件)
Greg Peacock
2020 年 8 月 6 日
Late to the question, but you could try this. Make sure you include it in your "yyaxis right" section.
yyaxis right
obj = findobj(gca,'type','line');
set(obj,'LineStyle','-');
set(obj,'Marker','none');
0 件のコメント
Takumi
2019 年 3 月 19 日
Try this at the end of your program.
obj = findobj(gca,'type','line');
set(obj,'LineStyle','-');
2 件のコメント
参考
カテゴリ
Help Center および File Exchange で Line Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!