GithubHelp home page GithubHelp logo

johnkeating1997 / plotpublication Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ruozhoulin/plotpublication

0.0 0.0 0.0 806 KB

Plot high quality figures for publication based on Matplotlib.

License: MIT License

Python 4.77% Jupyter Notebook 95.23%

plotpublication's Introduction

plot-publication

This repo could automatically adjust figure/subfigure size to fit the page that you want to insert the figure. In this way, the figure is presented as intended without being stretched and squeezed.

Why do we need this package?

When I write a manuscript, I always have to spend many time and effort adjusting the figure size. This is because the figure is often stretched or squeezed after being inserted into a page, caused by inconsistent size (usually the width) between the figure and the page. One direct negative effect is that the font size of labels, ticks, and legends is changed, as shown in the following figure. Although manually setting the figure size according to the page size can solve this problem, this work is laborious and the verbose code that adjusts figure size hampers the readability. That's why I decided to develop this package.

Getting Started

The easiest way to use this package is to put plot_publication.py in your working directory and then import it:

from plot_publication import *

Note:

  • plot_publication requires matplotlib.
  • Please use the provided method to import this package. Other import methods like import plot_publication could result in errors in the font family.

Using this package

After importing plot_publication, you can create a figure with appropriate size by:

# Create a figure with 6 subplots that fits an A4 page.
Fig = FigurePublication(3, 2)
fig, ax = Fig.fig, Fig.ax
# the following code can be identical to what you do with matplotlib
ax[0][0].plot(x1, y1, label='figure (1,1)')

It should be noted that FigurePublication() create a figure and set its size according to an A4 page with a normal margin in default. If you want to insert your figure into a page with a different page size and margin size, please input these values as parameters.

Examples

Please refer to this example.

plotpublication's People

Contributors

ruozhoulin 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.