Intersection of yline and x,y categorical data
Afficher commentaires plus anciens
I will not show the code which produces the data in the attached figure as I feel it is rendundant with my current issue.
In the figure attached, I have a series of points for which I have joined them by a line.
I also have a yline (50%) at which passes the previous plot line, once, around -7.5M. However, I want to have an exact value for this and to make the process automatic, rather than manual.
I have tried using various functions like interX and so on from file exchange but to no avail.
The data, and current plotting code is below:
Note - I did remove the first point of the data (ND) and then converted the xdata into numerical data, on the log scale but still had issues. Obviously, I removed the associated point from the yData vector.
I understand that this is probably the better way to do it, and then just plot the categorical case on top of the numerical case, like my code does.
% the original categorical x data
xS=categorical(["CTR" "-12" "-11" "-10" "-9" "-8" "-7"]);
xS = reordercats(xS,{'CTR' '-12' '-11' '-10' '-9' '-8' '-7'});
%Numerical version of above, removing the CTR entry (re-added back later)
cd = [1e-12 1e-11 1e-10 1e-9 1e-8 1e-7];
xS2 = log10(cd);
%The two different y data sets for each x data above
yS = [1 0.9995 0.9978 0.9815 0.8571 0.5576 0.4465]*100;
yS2 = [0.9995 0.9978 0.9815 0.8571 0.5576 0.4465]*100;
fig = figure(2);
%Actual plots
plot(xS,yS, '-o','Color','[0, 0.4470, 0.7410]',...
'LineWidth',3.5,'MarkerSize',20,...
'MarkerFaceColor','[0, 0.4470, 0.7410]','MarkerEdgeColor','k',...
'Linewidth',3);
hold on
yline(50, 'r--','Linewidth',3.5);
% Second to calc Ic50 value - uses numeric data
plot(xS2,yS2, '-o','Color','[0, 0.4470, 0.7410]',...
'LineWidth',3.5,'MarkerSize',20,...
'MarkerFaceColor','[0, 0.4470, 0.7410]','MarkerEdgeColor','k',...
'Linewidth',3);
xlabel('Dose [logM]'), ylabel('% Control')
leg = legend({'Cell Number','IC_5_0'});
leg.LineWidth=2.5;
leg.FontSize=28;
leg.NumColumns=1;
leg.LineWidth=2;
% Other plot stuff
box on
ax = gca;
set(gca,'linewidth', 2.5,'fontsize',28,'fontname','Helectiva') % Sets the width of the axis lines, font size, font
set(gca,'TickDir','out')
x0 = 50;
y0 = 50;
width=800;
height=600;
set(gcf,'position',[x0,y0,width,height])
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Graphics Object Properties dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
