Filter löschen
Filter löschen

How to plot a contourf ?

1 Ansicht (letzte 30 Tage)
Inês Mendes
Inês Mendes am 9 Jul. 2015
Kommentiert: Inês Mendes am 9 Jul. 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

Akzeptierte Antwort

Mike Garrity
Mike Garrity am 9 Jul. 2015
Bearbeitet: Mike Garrity am 9 Jul. 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))

Weitere Antworten (0)

Kategorien

Mehr zu Contour Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by