フィルターのクリア

How to add Line/Markers to an Axis Label?

19 ビュー (過去 30 日間)
Daniel
Daniel 2023 年 1 月 25 日
編集済み: dpb 2023 年 1 月 26 日
It is fairly common to add an example of either the line style or marker style to the Y-axis label of a plot when plotting multiple datasets to make the plot easier to understand. See attached examples. Is this possible to do in matlab?
I do not want to use a legend. Surprisingly I haven't been able to find any solutions on this.
  5 件のコメント
Daniel
Daniel 2023 年 1 月 25 日
For clarity. You do not need to use an additional legend when you can quickly identify it on the Y-axis. Another useful case is when there are a left and a right Y-axis and it makes it easier to differentiate the two, say dashed vs. solid line.
I don't feel this is terribly unique as I see it done in scientific literature plots occasionally. I know it is possible in other plotting softwares like Origin or Python.
I am just surprised there is no way to put the same lines or symbol examples that would appear in the legend into a label.
dpb
dpb 2023 年 1 月 25 日
編集済み: dpb 2023 年 1 月 26 日
Well, there are lots of little holes in handle graphics and annotation objects that weren't thought of in the beginning...annotation can draw line, but it is a different kind of line object than the one for plot; it has 'linestyle', but no 'marker' property. And, even if did, there's no facility to join disparate annotations types into a single coherent piece.
No hatching patterns, ...

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

採用された回答

Walter Roberson
Walter Roberson 2023 年 1 月 25 日
編集済み: Walter Roberson 2023 年 1 月 25 日
L = "G\prime ( \bullet ) and G\prime\prime ( \color{red}{\bullet}\color{black} ) (Pa)";
ylabel(L, 'interpreter', 'tex')
Note that \color is a mode; the color continues until it is switched off. Also note that I used tex interpreter for this. And \bullet .
To extract the marker shape from a line and map it to tex to draw a similar shape would be more work; I do not know if it is generally possible for all of the markers, given the limitations of MATLAB's TeX and LaTeX
  2 件のコメント
Daniel
Daniel 2023 年 1 月 25 日
This is a good answer and probably the closest we will get thank you.
Quickly playing around with latex, $^{\_\_\_\_}$ gives a nearly solid line. $\cdot\cdot\cdot$ gives a dotted line and $---$ gives a dashed line. Some more work could clean these up.
Walter Roberson
Walter Roberson 2023 年 1 月 26 日
I wonder whether some of the options described in https://linuxhint.com/latex-horizontal-line/ could be used ?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by