plotyy: changing the line-style to 'o--'

33 ビュー (過去 30 日間)
Abhinav
Abhinav 2018 年 5 月 31 日
コメント済み: Abhinav 2018 年 6 月 1 日
I have three line-plots on left y-axis and a bar plot on the right y-axis. how do I change line-style to 'o--' for every line on left y-axis. I am using following code, but it shows an error of 'Bad property value found'.
[Ax,hl1,hl2]=plotyy(time_step,surfaceflow1,prcp_datenum,prcp_excess,'line','bar');
set(hl1,'linestyle','--','linewidth',3) % gives error if I use 'o--' instead of '--'
hold(Ax(1))
plot(Ax(1),time_step,surfaceflow28,'o--','color','r','linewidth',3)
plot(Ax(1),time_step,surfaceflow59,'o--','color',[0,0.5,0],'linewidth',3)
datetick(Ax(1),'x','mmmm dd')
datetick(Ax(2),'x','mmmm dd HH:MM')
I have attached the figure that I get with this code and other formattings. I am not able to figure out a way to change the line style of blue-curve to 'o--' as in other cases.
  2 件のコメント
Stephen23
Stephen23 2018 年 6 月 1 日
編集済み: Stephen23 2018 年 6 月 1 日
@Abhinav: what you call line style is actually called the LineSpec or Line Specification. The LineSpec is a shorthand which lets you specify the color, line style, and marker shape. It can only be used when calling some high-level plotting functions (e.g. plot). You can read more about it here:
The Line Style only defines the line itself: it can be solid, dashed, dotted, or dot-dash (specified by '-', '--', ':', '-.' respectively). You will find the permitted LineStyles listed in the line properties, along with all of the permitted Markers. If you want to set the Marker then you need to set the Marker property, not the LineStyle property.
Abhinav
Abhinav 2018 年 6 月 1 日
Thank you, Stephen! It worked.

サインインしてコメントする。

採用された回答

Greg
Greg 2018 年 6 月 1 日
'o--' and others are shortcut inputs to plot commands when you don't pass a parameter. In this case, you are specifying a marker and a line style. When you pass the 'LineStyle' parameter, you can't include a marker identifier (the 'o'). Try:
set(hl1,'linestyle','--','marker','o','linewidth',3);
  1 件のコメント
Abhinav
Abhinav 2018 年 6 月 1 日
It works! Thanks a lot!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTwo y-axis についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by