Re-hash the intrinsic Matlab plot function to accept a string as a y input?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Walter Roberson
el 17 de Abr. de 2019
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' ?
Respuestas (1)
Steven Lord
el 17 de Abr. de 2019
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 comentario
nas illmatic
el 17 de Abr. de 2019
Editada: nas illmatic
el 17 de Abr. de 2019
Ver también
Categorías
Más información sobre Line Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!