How to change axis style?

8 vues (au cours des 30 derniers jours)
John
John le 26 Sep 2015
Commenté : Star Strider le 30 Sep 2015
How can I change the style of the axis lines? The a portion of the y-axis coincide with the curve being plotted. So I would like to have the y-axis in a different style (dashed maybe) so that the curve can be identified (plotting the curve in another color is not an option because ultimately the figure will be included in a black and white document). Any ideas?
clc;
close all;
clear all;
pa = 6;
upper_x = 40;
aut_x = 32;
upper_bnd_x=1.1*upper_x;
hours = 1200;
h_x = hours/upper_x;
upper_y =pa*upper_x;
upper_bnd_y=1.1*upper_y;
xlb=0;
xub=upper_bnd_x;
xubtick=upper_x;
n1 = 3;
x2 = linspace(0,upper_x,n1);
y2 = upper_y - pa*x2;
s21 = linspace(0,pa,n1);
s22 = pa.*ones(1,n1);
s23 = linspace(pa,2*pa,n1);
s2 = cat(2,s21,s22,s23);
xs21 = zeros(1,n1);
xs22 = linspace(0,upper_x,n1);
xs23 = upper_x.*ones(1,n1);
xs2 = cat(2,xs21,xs22,xs23);
dt2 = upper_x.*ones(1,n1);
dy2=linspace(pa,4,n1);
dx2=19+2.*dy2;
dt22 = aut_x.*ones(1,n1);
figure
set(gcf,'units','inches','renderer', 'painters');
pos = get(gcf,'pos');
set(gcf,'Units','inches',...
'Position',[pos(1) pos(2) 2.8 2]);
plot(xs2,s2,'Color','black');
xlabel('measure x')
ylabel('measure y')
set(gca,...
'Units','normalized',...
'FontUnits','points',...
'FontWeight','normal',...
'FontSize',9,...
'FontName','Times',...
'XLim',[xlb xub],...
'XTick',[0,aut_x,xubtick],...
'YTick',[pa],...
'YLim',[0 2*pa],...
'Box','off')
set(gca, 'Position', get(gca, 'OuterPosition') - ...
get(gca, 'TightInset') * [-1 0 1 0; 0 -1 0 1; 0 0 1 0; 0 0 0 1]);
hold on;
plot(dt2,s21,':','color','black');
plot(dt22,s21,':','color','black');
hold off;

Réponse acceptée

Star Strider
Star Strider le 26 Sep 2015
Modifié(e) : Star Strider le 26 Sep 2015
You can change the grid lines by setting the GridLineStyle property. The box itself you can only turn on and off.
  10 commentaires
John
John le 30 Sep 2015
I thank you very much, Star Strider. You've gone through more loops with me than I ever expected.
Here is the bottom line: I was using R2014a and it didn't work there at all! Since I could get R2015, I did and it did work there as you told me it would.
I don't know why this was the case, but I will keep both versions installed, even if it is a burden to my smallish SSD drive.
Incidentally, it seems that MathWorks finally ditched the ubiquitous "student version of matlab" that spoiled every single .pdf (thumbs up to them!)
Star Strider
Star Strider le 30 Sep 2015
My pleasure.
This was an interesting problem. I still have R2014a on this machine (the ‘old’ handle graphics are easier to use in some situations), but I used R2015b here.
I use the PDF suite produced by Tracker Software whenever I have to do a PDF of anything. I’ve used it for years (with updates), and like it.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Just for fun dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by