Re-hash the intrinsic Matlab plot function to accept a string as a y input?
1 回表示 (過去 30 日間)
古いコメントを表示
I am using the matlab 'plot' function which uses x, y as inputs. The x axis is time (which is a number in seconds and is easy), however the y axis is actually a number/string combination, for example, E312, E313. The plot function breaks since it is only expecting a numeric value, however I want the ylabel (for that corresponding point) to display 'E312' (in this example); how is that possibe?
2 件のコメント
Walter Roberson
2019 年 4 月 17 日
If I have (say) 500 pixels available for y axes, then how far up should 'E312' appear? How far up should 'E313' appear? Is 'E1000' above or below 'E2' ?
回答 (1 件)
Steven Lord
2019 年 4 月 17 日
You could turn your text data into a categorical array then plot with that categorical data as the Y input.
colors = categorical({'r' 'b' 'g', 'g' 'r' 'b', 'b' 'r' 'g'}, ...
{'r' 'g' 'b'},{'red' 'green' 'blue'});
plot(1:9, colors)
Alternately, if you want to plot numeric data and just have the labels on the axes change, use the yticklabels function.
1 件のコメント
参考
カテゴリ
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!