s:
The properties that can be set for a figure
is referenced here.
You could then use:
figure_number = 1; x = 0; % Screen position y = 0; % Screen position width = 600; % Width of figure height = 400; % Height of figure (by default in pixels) figure(figure_number, 'Position', [x y width height]);
To set the figure size in a graph using Matplotlib library in Python, you can use the figsize
parameter in the Figure
class. This parameter takes a tuple of width and height values in inches. For example:
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(10, 5)) # width=10, height=5
ax = fig.add_subplot(111)
ax.plot([1,2,3,4], [10,20,25,30])
plt.show()
In this example, we created a figure object with width and height of 10 inches and 5 inches, respectively. The add_subplot
method is used to create an axis object within the figure and then a line plot is created using the plot
method. The final step is to display the plot using the show
method.
You can also set the size of the plot using the set_size_inches
method of the Figure
class. For example:
fig = plt.figure()
fig.set_size_inches(10, 5) # width=10, height=5
ax = fig.add_subplot(111)
ax.plot([1,2,3,4], [10,20,25,30])
plt.show()
In this case, the figure object is first created and then its size is set using the set_size_inches
method. The rest of the steps are similar to the first example.