Code Monkey home page Code Monkey logo

mplfig's Introduction

mplfig

Matplotlib by default only allows you to export your figures in formats that are used for publishing (e.g., a .pgf file, a resterized .png file, etc.). MATLAB allows you to save files in a .fig format which allows you to change the plot very easily (say, to fix a typo on an axis label, or to change the colorscheme). mplfig strives to bring this functionality to matplotlib. With mplfig, you can save your matplotlib files and load them right back up in another python script.

Example

First, create a figure and save with it mplfig.

import mplfig
import matplotlib.pyplot as plt

xs = list(range(10))
ys = list(map(lambda x: x**2, xs))

plt.plot(xs, ys)
mplfig.save_figure(plt.gcf(), 'myfig.mplpkl')

plt.show()

Before

Next, load it back up and change the figure!

import mplfig
import matplotlib.pyplot as plt

fig = mplfig.load_figure('myfig.mplpkl') # Load the saved figure

axes = fig.get_axes()
axes[0].set_xlabel('$x$') # Add an x label
axes[0].set_ylabel('$y = x^2$') # Add a y label
axes[0].lines[0].set_marker('o') # Add a circle marker

plt.show()

After

Install

mplfig is on PyPI

pip3 install -U mplfig

mplfig's People

Contributors

paulvirally avatar

Stargazers

Pho Hale avatar

Watchers

 avatar

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.