![]() ![]() While the previous section showed you how to change the size in one argument, these functions give you the control to modify these parameters individually. ![]() Matplotlib also provides ways to more explicitly define the height and width individually, using the set_fightheight() and set_figwidth() functions. Changing Plot Size in Matplotlib Using set_figheight and set_figwidth In the next section, you’ll learn how to use Matplotlib to set width and height individually. This returns the following image: Changing the DPI of a Matplotlib Figure ![]() Let’s change our DPI to 200 pixels per inch: # Changing the DPI of a Matplotlib Chart In order to mofidy this, you can use the dpi= parameter on the figure object. By default, Matplotlib uses a DPI of 100 pixels per inch. In order to finely tune your printable reports, you can also control the DPI of the charts your produce. Matplotlib allows you to prepare print-friendly reports. This can be done by multiplying a value in inches by 2.54 to calculate it in centimeters. If you’re more accustomed to working with centimeters, you first need to convert the measurement to centimeters. We passed in a tuple containing the width and the length in inches. In the code above, we assigned the figsize= parameter in order to specify the size of the figure we want to use. In the code above, we accessed the Figure that was created by default. This returns the following image: Using figsize to Change Matplotlib Figure Size Let’s take a look at how we can do this: # Changing the figure size using figsize= Because of this, we first need to instantiate a figure in which to host our plot. As the name of the argument indicates, this is applied to a Matplotlib figure. One of the simplest and most expressive ways of changing the plot size in Matplotlib is to use the figsize= argument. show() method to display the visualizationĬhanging Plot Size in Matplotlib Using figsize ![]()
0 Comments
Leave a Reply. |