Semilog plot with background image

2 views (last 30 days)
Stanley Kubrick
Stanley Kubrick on 19 Feb 2015
Commented: Star Strider on 19 Feb 2015
I've modelled lines from image files and now I want to check that what I've done is correct. I want to plot the equations I came up with on top of the image files. So far, I can create two different figures, but I cannot plot both on top of one another (preferably with the image file slightly transparent). I've see a solution for non-log plots, but cannot seem to find anything that would work in my case. See below the code, as well as 'sample.png'.
clear
clc
close all
%%Create X-Axis
x = linspace(0,100,1001);
%%Low Variables
al = 10.95138337;
bl = 7.440851134;
cl = 1.51185755;
dl = -0.162527357;
yl = al + bl*log(x) + cl*log(x).^2 + dl*log(x).^3;
semilogx(x,yl,'g')
hold on
grid on
%%Medium Variables
am = 20.6143819;
bm = 9.539354014;
cm = 1.206316519;
dm = -0.129084187;
ym = am + bm*log(x) + cm*log(x).^2 + dm*log(x).^3;
semilogx(x,ym,'y')
%%High Variables
ah = 30.29206721;
bh = 12.42540544;
ch = 1.390071294;
dh = -0.26660217;
yh = ah + bh*log(x) + ch*log(x).^2 + dh*log(x).^3;
semilogx(x,yh,'r')
%%Plot the image
im = imread('sample.png');
figure
%define plot extent so that image can be aligned with plot
xrng = [0 100];
yrng = [0 100];
imagesc(xrng,yrng,im);
ax1 = gca;
%get rid of pixel ticklabels
set(ax1,'YTickLabel', [], 'XTickLabel', [])
%color=none to make the image visible
ax2 = axes('Position',get(ax1,'Position'),'Color','none','XScale', 'log');
ylim(yrng)
xlim(xrng)

Answers (0)

Community Treasure Hunt

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

Start Hunting!