Borrar filtros
Borrar filtros

How to plot a contourf ?

1 visualización (últimos 30 días)
Inês Mendes
Inês Mendes el 9 de Jul. de 2015
Comentada: Inês Mendes el 9 de Jul. de 2015
Hi guys,
Do any of you know if it is possible to plot a contourf in which my y axis corresponds to a string array, my x axis to a time array, and my Z to a numeric array?
Thanks in advance!
Inês

Respuesta aceptada

Mike Garrity
Mike Garrity el 9 de Jul. de 2015
Editada: Mike Garrity el 9 de Jul. de 2015
The easiest way to deal with non-numeric data is to give contour numeric indices into the data and use the data as your TickLabels:
xoptions = {'left','center','right'};
yoptions = {'bottom','middle','top'};
nx = length(xoptions);
ny = length(yoptions);
contourf(1:nx,1:ny,randn(ny,nx))
set(gca,'XTick',1:nx,'XTickLabels',xoptions)
set(gca,'YTick',1:ny,'YTickLabels',yoptions)
Datetimes are similar, but you need to turn them into strings before using them as tick labels:
yoptions = datetime(2015,1:3,1);
ny = length(yoptions);
set(gca,'YTick',1:ny,'YTickLabels',datestr(yoptions))

Más respuestas (0)

Categorías

Más información sobre Contour Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by