How to plot a contourf ?

1 次查看(过去 30 天)
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

采纳的回答

Mike Garrity
Mike Garrity 2015-7-9
编辑:Mike Garrity 2015-7-9
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))

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Contour Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by