Giter Site home page Giter Site logo

prettyplot's Introduction

PrettyPlot

This project is created to draw pretty figures.

How to use it:

First, intall it:

git clone https://github.com/xinyu-yang/prettyplot.git
pip install -e ./prettyplot

Then, you can import and use it:

import numpy as np
import prettyplot as ppt
from prettyplot.config import *

fig_setting = {
                "title": "The title of the figure",
                # The scale to expand, which is used to set the figure size
                "scale": (0.5, 0.5),
                "title_size": 16,
                # The size of x and y labels
                "label_size":14,
                # The size of legend
                "legend_size": 12,
                ...
              }
settings = [
    {
        "color": GNU_COLOR[0],
        "label": "sin(x)",
        "linestyle": "-",
        "marker": MARKERSTYLE[0],
    },
    ...
]

x = np.linspace(0, 2*np.pi, 20)
y1 = np.sin(x)
y2 = np.cos(x)

fig, ax = ppt.line.lines([x, x], [y1, y2], settings, fig_setting)

plt.show()

The provided funtion provide basic functions, you can define more advanced parameters with the retured fig and ax variables.

# Set the border the figure
ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False)

# Set the background color of the image
fig.patch.set_visible(False)
ax.patch.set_visible(False)

# The legend
ax.legend(frameon=False, fontsize=12, loc="lower right")

# Plot grid
# plt.grid(linestyle="--")

# Show
plt.show()

# save figure
# fig.savefig("test.pdf", transparent=True, bbox_inches='tight')

There is an example that can cover all the features.

prettyplot's People

Contributors

xinyuyoung avatar xinyu-yang 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.