This post shows how to set matlab figure size (width and height) and position (on screen). Or how to set custom graph size and position in MATLAB. How to set matlab plot width, and plot height and display position on the screen? Answer of all these questions given in this post.
Contents
How to plot graph in MATLAB
There are various MATLAB functions which helps to show graphs of your custom needs. for example.
Types of Graphs and Charts
- Line Graph or Chart
- Dot Graph or Plot
- Scatter Plot
- Bar Chart/Graph
- Pie Chart
- Histogram Chart
- Area Chart
- Radar Chart
- Polar Plots
- Smith Chart
- Logarithmic Chart, etc.
Sample code to plot sine wave
t = -pi:pi/1000:pi; x = sin(2*pi*t); plot(t,x); grid on;
Output of above MATLAB Code
In the above matlab graph there is default location on screen. Width and height of the graph is also default. Sometimes we need various figures, but default is size is not useful or not fit in our needs.
So you have to resize manually on screen and save the graph/figure.
Hopefully, there is solution to MATLAB figure/graph position on screen as well as desired width and height. Below code to set position and height and width of the graph.
For this first you need to create the object of the figure, and then set the Position property to the object.
t = -pi:pi/1000:pi; x = sin(2*pi*t); objFIG = figure(1); objFIG.Position = [589 471 800 500]; % [x y width height] plot(t,x); grid on;
x is position on x-axis considering lower left corner of screen as origin.
y is position on y-axis considering lower left corner of screen as origin.