Creating 2d Plots colors representing log scale weights

1 次查看(过去 30 天)
Hi everyone,
So I have a 2d plot that represents the geometry of a structure and need to plot wights i calculated on each segment. The weights can range from 0 (could make this eps for plotting) to some unknown quantity. I want to plot the log10 of the weights and adjust the colorbar accordingly. I have attached my two functions that do this. One is part of a class that is called by a plot function.
Main plot function:
set(0,'DefaultFigureVisible','off')
temp=[arteryArray.sectionArray,veinArray.sectionArray];
maxHits=max([temp.hits]);
maxDose=max([temp.dose]);
xc=mean(particleArray(:,1));
yc=mean(particleArray(:,2));
ang=0:0.01:2*pi;
xp=maxElectronRange*cos(ang);
yp=maxElectronRange*sin(ang);
fig1=figure('visible','off');
ax1=gca;
plot(particleArray(:,1),particleArray(:,2),'x')
hold on
%plot(xc+xp,yc+yp);
title('Hits Plot')
colormap cool
caxis([0,maxHits]);
colorbar;
fig2=figure('visible','off');
ax2=gca;
plot(particleArray(:,1),particleArray(:,2),'x')
hold on
%plot(xc+xp,yc+yp);
title('Dose Plot')
colormap cool
caxis(([0,log10(maxDose)]));
colorbar;
for i = 1:length(arteryArray)
%Artery
arteryArray(i).plotHits(ax1,maxHits)
arteryArray(i).plotDose(ax2,maxDose)
%Vein
veinArray(i).plotHits(ax1,maxHits)
veinArray(i).plotDose(ax2,maxDose)
end
set(0,'DefaultFigureVisible','on')
figure(fig1)
hold off
figure(fig2)
hold off
Called function in classes: This is where the normalization will happen to the data in the color
function plotDose(obj,ax,norm)
meanRadius=mean([obj.sectionArray.outerRadius]);
for i =1:length(obj.sectionArray)
startPoint=obj.sectionArray(i).startpoint;
endPoint=obj.sectionArray(i).endpoint;
x1 = [startPoint(1);endPoint(1)];
y1 = [startPoint(2);endPoint(2)];
z1 = [startPoint(3);endPoint(3)];
lineweight=2*obj.sectionArray(i).outerRadius/meanRadius;
cm = colormap; % returns the current color map
colorID = max(1, sum(log10(obj.sectionArray(i).dose) >...
[0:1/length(cm(:,1)):1]));
color = cm(colorID, :);
plot(ax,x1,y1,'Color',color,'LineWidth',lineweight);
end
end

回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by