MATLAB Answers

How to change axis style?

50 views (last 30 days)
John on 26 Sep 2015
Commented: Star Strider on 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?
close all;
clear all;
pa = 6;
upper_x = 40;
aut_x = 32;
hours = 1200;
h_x = hours/upper_x;
upper_y =pa*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);
dt22 = aut_x.*ones(1,n1);
set(gcf,'units','inches','renderer', 'painters');
pos = get(gcf,'pos');
'Position',[pos(1) pos(2) 2.8 2]);
xlabel('measure x')
ylabel('measure y')
'XLim',[xlb xub],...
'YLim',[0 2*pa],...
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;
hold off;


Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 26 Sep 2015
Edited: Star Strider on 26 Sep 2015
You can change the grid lines by setting the GridLineStyle property. The box itself you can only turn on and off.


Show 7 older comments
Star Strider
Star Strider on 30 Sep 2015
This seems to work for me (with the plot in your latest code, and appended just after it):
saveas(gcf, 'John.png');
J = imread('John.png');
I had to enlarge it manually to see everything, but it all seemed to be there (in R2015b).
If this doesn’t work as you want it to, I would contact MathWorks Tech Support for help.
John on 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 on 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.

Sign in to comment.

More Answers (0)

Sign in to answer this question.