Matlab绘图图像作为图形的背景 [英] matlab plot image as background to graph

查看:1125
本文介绍了Matlab绘图图像作为图形的背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张要设置为正在制作的情节背景的图像.但是,它将其绘制为使得图像沿轴([0 1000 0 1000])倾斜,而我的图形的轴则小得多:([24.5 24.6 67 67.1]).我如何对齐它,以使图像与图表具有相同的比例?

I have an image that I would like to set as the background of plot I am making. However it plots it so that the image taks up the axis([0 1000 0 1000]) while the axis for my graph is much smaller: ([24.5 24.6 67 67.1]). How do I align it so that the image is on the same scale as the graph?

我正在执行以下命令:

h = figure;
hold on
voronoi(lats,longs);
I=imread('my_fig.png');
hi = imagesc(I);
set(hi,'alphadata',.5);

推荐答案

您可以使用正确的xy向量调用image,就像这样(假设您的数据在x):

You can just call image with the right x and y vectors, like so (assuming your data is in x and y):

xImg = linspace(min(x), max(x), size(I, 2));
yImg = linspace(min(y), max(y), size(I, 1));
image(xImg, yImg, I, 'CDataMapping', 'scaled');
hold on;
plot(x, y);

换句话说,为图像的每个维度生成一个向量,该向量具有与图像的那个维度相同的点数,但是介于数据范围之间.

In other words, generate a vector for each of the dimensions of the image that has the same number of points as that dimension of the image but goes between the range of your data.

这篇关于Matlab绘图图像作为图形的背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆