# Resizing plots

Depending on the programming language (R or Python) and visualization package you use, plots you create inside DataLab will appear with different dimensions. This article describes the default behavior for the most common visualization packages and how you can customize it to suit your needs.

## Python

A workbook with the code samples in this article is publicly available [here](https://app.datacamp.com/workspace/w/fec49d15-ff91-4ace-b1a0-a8420c8fb3fd/edit?file=notebook.ipynb).

### Matplotlib and Seaborn

By default, figures will be 6.4 x 4.8 inches. If the output area of a code cell is smaller, the image will be scaled to fit inside it.&#x20;

<figure><img src="/files/usYFIkxTu4XKgGfxxuiy" alt=""><figcaption></figcaption></figure>

You can change the size of a specific plot by including the following code before you create the plot:

```python
from matplotlib.pyplot import figure
figure(figsize=(12, 6))
```

If you want to set a different deafult figure size for all plots you're creating in your notebook, you can include the following snippet at the top of your notebook:

```python
from matplotlib.pyplot import plt
plt.rcParams["figure.figsize"] = (12, 6)
```

### Plotly

For plots generated in Plotly, the width is adjusted to fit the with of the output area of the code section (which adjusts with the width of your viewport). The default height is 450 pixels.

<figure><img src="/files/baCbErNJ0YZOPVfw5H1V" alt=""><figcaption></figcaption></figure>

You can override these defaults using the `width` and `height` arguments:

<figure><img src="/files/l8yjBdjOWNcmQmjusTIe" alt=""><figcaption></figcaption></figure>

## R

A workbook with the code samples in this article is publicy available [here](https://app.datacamp.com/workspace/w/d978e7cb-1029-42df-abde-a04dc1226051/edit?file=notebook.ipynb).

### Base plotting and ggplot2

By default plots will be 7 x 7 inches, with a resolution of 120 dots per inch:

<figure><img src="/files/f36uzqlpvcYh4BHyNkTJ" alt=""><figcaption></figcaption></figure>

You can control this by setting `repr.plot` options. Note that, once called, these options will be used for all plots you generate from that point on.

<figure><img src="/files/azsWOB6egmEONlxqqjpl" alt=""><figcaption></figcaption></figure>

### Plotly

For plots generated in Plotly, the width is adjusted to fit the with of the output area of the code section (which adjusts with the width of your viewport). The default height is 450 pixels.

<figure><img src="/files/UlJ2Lx4P2x2ePTDPi6tA" alt=""><figcaption></figcaption></figure>

You can override these defaults using the `width` and `height` arguments:

<figure><img src="/files/AMcC5DcWBRHWE0ckBlGx" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://datalab-docs.datacamp.com/guides/resizing-plots.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
