# Pytho Plotly save graphics with width and hight in mm or cm or inch

**URL:** https://community.plotly.com/t/pytho-plotly-save-graphics-with-width-and-hight-in-mm-or-cm-or-inch/22427
**Category:** 📊 Plotly Python
**Created:** [April 18, 2019, 5:44am UTC](https://community.plotly.com/t/pytho-plotly-save-graphics-with-width-and-hight-in-mm-or-cm-or-inch/22427 "2019-04-18T05:44:02Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![bokken](https://avatars.discourse-cdn.com/v4/letter/b/ad7895/32.png) [@bokken](https://community.plotly.com/u/bokken)
#### Post date: [April 18, 2019, 5:44am UTC](https://community.plotly.com/t/pytho-plotly-save-graphics-with-width-and-hight-in-mm-or-cm-or-inch/22427/1 "2019-04-18T05:44:02Z")

</div>

I save a plotly plot to a pdf. How can I set the size of the plot in mm or inch? The plot size and the grid has to match a certain length.

I absolutely cant wrap my head around logic Pixel and so forth.

import [plotly.io](http://plotly.io) as pio  
pio.write\_image(fig\_, “plot.pdf”,width=1000, height=800) #how to put units here

In ggplot it would look something like  
ggsave(“filename.pdf”, plot = last\_plot(), width = 5, height = 5, units = “in”)

---

<div class="post-metadata">

### Author: ![jmmease](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmmease/32/3706_2.png) [@jmmease](https://community.plotly.com/u/jmmease)
#### Post date: [April 22, 2019, 10:37am UTC](https://community.plotly.com/t/pytho-plotly-save-graphics-with-width-and-hight-in-mm-or-cm-or-inch/22427/2 "2019-04-22T10:37:01Z")

</div>

Hi @bokken,

I just added a comment on an open orca issue that has a formula for specifying PDF dimensions in inches. See [https://github.com/plotly/orca/issues/205#issuecomment-485387841](https://github.com/plotly/orca/issues/205#issuecomment-485387841). Hopefully we’ll work out a simpler way to support this in the future, but I hope this helps in the meantime!

-Jon

---

<div class="post-metadata">

### Author: ![Carl](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/carl/32/8296_2.png) [@Carl](https://community.plotly.com/u/Carl)
#### Post date: [January 7, 2023, 6:22pm UTC](https://community.plotly.com/t/pytho-plotly-save-graphics-with-width-and-hight-in-mm-or-cm-or-inch/22427/3 "2023-01-07T18:22:36Z")

</div>

This is great. I tried the solution there and it _almost_ works for me. However, there are two problems:

(i) After every graph, there is a blank page. I am using landscape mode.  
(ii) The page size is still not _exactly_ the same as that created by matplotlib and pdfpages, despite using 20" and 12" for width and height. It’s very close however. I assume that either the ppi number is slightly out, or, more likely, the pdf dimensions have been rounded to the nearest ".

I’m not sure that (ii) matters, but (i) is a biggie. Perhaps I can fix by tinkering with my output plot resolution …
