How to plot 3D data as a 2D color plot (with axes representing parameter values)?
118 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Using the imagesc function I can get a figure that looks like this:
However, the problem is the axes: the numbers simply list the index of each point in the matrix. I want each of those points in the matrix of output mapped to combinations of input values. As of now the axes are meaningless because they don't represent the phyiscal parameters I was using.
I found a few similar questions (e.g. here, and here), but I haven't quite figured it out. Is there no straightforward way to map each axis scale to a vector of parameter values? I tried changing the 'XData' property in the figure, but that just turned the whole image white, while the x-axis scale remained unchanged. I don't get it.
I'm looking into the pcolor function, and I think I could get that to work properly if necessary (although it looks much worse with default settings due to gridlines), but isn't there a way to get this to work with imagesc?
1 commentaire
convert_to_metric
le 17 Mai 2019
Hi Alexei,
If you are still looking for an answer, please provide your data and a description of what part of the data represents each axis.
Plus de réponses (1)
Josh
le 21 Mai 2019
I think I get what you're getting at.
When you use imagesc, you're plotting an image. Images have coordinates just like lines and patches. By default, the x and y values of the image will be its pixel coordinates. You can adjust this by setting the XData and YData properties of the image:
% Create a dummy image
im = bsxfun(@times, sin((0:99)/99*2*pi), cos((0:99)'/99*2*pi));
% Plot the image, and rescale so that the one corner of the image is
% plotted at [11, 10.7] and the opposite corner at [15, 18.2]:
imagesc(im, 'XData', [11, 15], 'YData', [10.7 18.2]);
When you set XData and YData of the axes, you're just adjusting what part of the graph is visible. If you're seeing all white, you're probably moving off into space somewhere where no part of the image is visible.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!