Giter VIP home page Giter VIP logo

Comments (6)

LaurentRDC avatar LaurentRDC commented on September 13, 2024 1

pandoc-pyplot version 2.1.5.0 now supports two additional parameters, in the global config-file only: tight_bbox: true|false and transparent: true|false. See the updated README for instructions.

I didn't add those parameters for individual figures, but if you want that, don't hesitate to re-open this issue!

from pandoc-pyplot.

LaurentRDC avatar LaurentRDC commented on September 13, 2024

Hey @seldridge ,

That's a good idea. Initially, that's why I had the DPI option.

What you can do right now

Add the bbox_inches="tight" option to pandoc-pyplot plots by using a preamble of the following kind:

style.py:

import matplotlib.pyplot as plt

plt.rcParams['savefig.bbox']='tight' # Sets the default value in plt.savefig(...)

In your Markdown/Latex:

{.pyplot include=style.py}
...

You can do that with most arguments to plt.savefig, e.g. facecolor, edgecolor, figsize, etc. See here for a guide to Matplotlib customization.

In the future

I can see two paths forward:

  1. Allow arbitrary arguments as a string that is directly passed to plt.savefig;
  2. Add relevant parameters to the Haskell interface, like dpi right now.

Looking at all the supported arguments in the latest Matplotlib release, there are a lot of potential that might never be used.

Beyond bbox_inches, are there any other savefig parameters you want to change?

from pandoc-pyplot.

LaurentRDC avatar LaurentRDC commented on September 13, 2024

Thank you for your kind words as well.

from pandoc-pyplot.

seldridge avatar seldridge commented on September 13, 2024

Ah, cool! rcParams does the trick. Thanks for the pointer to Matplotlib customization. (I had gone ahead and locally, crudely patched the saveFig call to always use my bbox_inches parameter.) I guess I'm torn as this approach is really sufficient and future-proof for API changes to saveFig...

Of your future ideas, I'd prefer (2) just because there's some notion of type safety as opposed to passing a string directly to saveFig.

Of the available parameters, I only use bbox_inches and Transparent.

from pandoc-pyplot.

LaurentRDC avatar LaurentRDC commented on September 13, 2024

I can see why you would want to use the transparent parameter often, especially on the web. I've often had to use bbox_inches for more advanced plots as well. I will add both right now.

from pandoc-pyplot.

seldridge avatar seldridge commented on September 13, 2024

Fix looks great, thanks!

from pandoc-pyplot.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.