Misalignment Ticks and Line when changing linewidth
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
So I'm getting a misalignment between a line and my ticks, using version R2016a (and can't update it on the pc that is using it).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/278884/image.png)
I can't find any matlab code that let's me fix this, I looked up the code to control ticks and ticklabels.
my code is below:
Pos_size=[100 100 800 400];
FSax=12;
FWax='bold';
FStitle=16;
FWtitle='bold';
MkSz=20;
Tfig5='Voltage vs FWHM';
Xlab4='Applied potential (V)'; %figs 4 and 5
YlabL1='CPM (M)'; %figs 1 and 2 and 4 and 5
%% plotting figure 5
h5=figure(5);
title(Tfig5,'FontSize',FStitle,'FontWeight',FWtitle)
xlabel(Xlab4,'FontSize',FSax,'FontWeight',FWax)
ylabel(YlabL1,'FontSize',FSax,'FontWeight',FWax)
set(h5,'Position',Pos_size);
hold on
ylim([0 400]);
hax5(1)=plot(Voltage,FWHMVolt,'.-','Linewidth',2,'MarkerSize',MkSz);
ax5=h5.CurrentAxes;
set(ax5,'FontSize',FSax,'FontWeight',FWax,'LineWidth',1);
line([0 0], get(ax5, 'ylim'),'color',[0.7 0.7 0.7],'linestyle','--','Linewidth',1.5); % this is my line (in my actual script I use vline but that's a file from mathworks but does the exact same) -> vline(0,'color',[0.7 0.7 0.7],'linestyle','--','Linewidth',1.5);
box on
% data if someone wants to run the code themselves
Voltage =
-0.1000
0
0.0100
0.0300
0.0500
0.0700
0.1000
0.3000
0.5000
0.7000
0.9000
FWHMVolt =
50
146
145
143
141
141
145
244
304
334
351
3 commentaires
Réponses (1)
Harsha Priya Daggubati
le 26 Mar 2020
Hi,
I could not reproduce the same in MATLAB R2019b. If it is not okay for you to update to recent versions, then you could try moving your line to align with the ticks as a workaround.
1 commentaire
Voir également
Catégories
En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!