Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I save a plot with closed boxed area in MATLAB?

How can I close the plot area with black lines in the top and right side when I save a plot?

I don't have any idea how to make it or how to search, if anyone knows please tell me.

For example look at the plot shown below, where the lines are missing:

blah

like image 605
user3683409 Avatar asked Dec 06 '25 04:12

user3683409


1 Answers

Before you save your image, use the box command. This will enclose your plot to have the surrounding black box as you have specified in your example image. Simply call:

box on;

To turn it off, do:

box off;

Example:

%// Plot a line from 1 to 5 for x and y
x = 1:5;
y = 1:5;
plot(x,y);
box on;

This is what the plot looks like:

enter image description here

If you were to turn boxing off, this is what the plot looks like:

enter image description here

box off; is the default behaviour for plot, as you have seen in the example image you have shown. Simply call box on; after the plot is shown and before you save your image to get the desired effect.

like image 175
rayryeng Avatar answered Dec 07 '25 23:12

rayryeng



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!