Skip to content

Commit

Permalink
Merge a3b9cda into ac7e2c7
Browse files Browse the repository at this point in the history
  • Loading branch information
CDonnerer committed Dec 12, 2020
2 parents ac7e2c7 + a3b9cda commit 69dc824
Show file tree
Hide file tree
Showing 6 changed files with 320 additions and 140 deletions.
114 changes: 46 additions & 68 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ shellplot
Shellplot is the plotting package that you didn't know you needed. Plotting,
straight outta the command line.

Docs: https://shellplot.readthedocs.io/en/latest/
Please take a look at the `documentation`_, which contains many `examples`_.


Installation
============
Expand All @@ -35,73 +36,45 @@ Run::
pip install shellplot


Usage
======

Simply pretend you're using matplotlib's pyplot::

import numpy as np
import shellplot as plt

x = np.arange(-3, 3, 0.05)
y = np.cos(x) ** 2

plt.plot(x, y)

1.0┤ +
|+ +++++ +
| + + + +
| + + + +
0.75┤ + + + +
| + ++ ++ +
| + + + +
| + + + +
0.5┤ + + + +
| + + + +
| + + + +
| + + + +
0.25┤ ++ ++ ++ ++
| ++ + + ++
| ++ ++ ++ ++
0.0┤ ++++++ ++++++
├------------------┬-------------------┬-------------------┬
-3 -1 1 3



Shellplot replicates the matplotlib API, except where it doesn't.


Pandas backend
--------------

For your pleasure, you can use shellplot via pandas::

import pandas as pd
pd.set_option("plotting.backend", "shellplot")

x = np.random.randn(1000)
pd.Series(data=x, name="my_fun_distribution").hist(bins=10)

counts
286┤
| ____
| ____| |
| | | |
215┤ | | |____
| | | | |
| | | | |
| | | | |
144┤ ____| | | |
| | | | | |____
| | | | | | |
| | | | | | |
73┤ | | | | | |
| ____| | | | | |____
| ____ ____| | | | | | | |____
├-------------┬-------------┬--------------┬-------------┬--
-4.0 -2.0 0.0 2.0 4.0
my_fun_distribution
Quickstart
===========

As shellplot replicates the `matplotlib`_ API, it's as easy as::


>>> import shellplot as plt
>>> df = plt.load_dataset("penguins")
>>> plt.plot(df["bill_length_mm"], df["flipper_length_mm"], color=df["species"])

flipper_length_mm
|
237┤
|
| o o oo o o o
| ooo o o o
| ooooo
223┤ o oooo ooo oo o
| o o ooo oo oo oo o o
| oo oo ooooo oo o
| o o o ooooo o oo o
209┤ oo oo + oooo o oo* * *
| + o oo o o * *
| + o * ** **
| + + +++ * * *** * *
| + ++++ + +++++ * + * * ** * **
195┤ +++ + +++ +++++++ + ** * * * * * *
| + ++ +++ +++++++++ + ** ** * * **
| + + ++++++ ++++++ ++ + **** *
| + ++++++ ++ ++ +* * * * * *
| + + ++ + ++
181┤ + +++++ + +* *
| + + + + *
| + + Adelie
| + * Chinstrap
167┤ o Gentoo
├------------┬-------------┬-------------┬-------------┬-------------┬
31 37 43 49 55 61
bill_length_mm



Expand All @@ -110,3 +83,8 @@ Note

This project has been set up using PyScaffold 3.2.3. For details and usage
information on PyScaffold see https://pyscaffold.org/.


.. _documentation: https://shellplot.readthedocs.io/en/latest/
.. _examples: https://shellplot.readthedocs.io/en/latest/examples.html
.. _matplotlib: https://matplotlib.org/contents.html#
93 changes: 51 additions & 42 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
import inspect
import shutil

__location__ = os.path.join(os.getcwd(), os.path.dirname(
inspect.getfile(inspect.currentframe())))
__location__ = os.path.join(
os.getcwd(), os.path.dirname(inspect.getfile(inspect.currentframe()))
)

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.join(__location__, '../src'))
sys.path.insert(0, os.path.join(__location__, "../src"))

# -- Run sphinx-apidoc ------------------------------------------------------
# This hack is necessary since RTD does not issue `sphinx-apidoc` before running
Expand Down Expand Up @@ -49,7 +50,7 @@
cmd_line = cmd_line_template.format(outputdir=output_dir, moduledir=module_dir)

args = cmd_line.split(" ")
if parse_version(sphinx.__version__) >= parse_version('1.7'):
if parse_version(sphinx.__version__) >= parse_version("1.7"):
args = args[1:]

apidoc.main(args)
Expand All @@ -63,35 +64,43 @@

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.todo',
'sphinx.ext.autosummary', 'sphinx.ext.viewcode', 'sphinx.ext.coverage',
'sphinx.ext.doctest', 'sphinx.ext.ifconfig', 'sphinx.ext.mathjax',
'sphinx.ext.napoleon']
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
"sphinx.ext.autosummary",
"sphinx.ext.viewcode",
"sphinx.ext.coverage",
"sphinx.ext.doctest",
"sphinx.ext.ifconfig",
"sphinx.ext.mathjax",
"sphinx.ext.napoleon",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix of source filenames.
source_suffix = '.rst'
source_suffix = ".rst"

# The encoding of source files.
# source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = u'shellplot'
copyright = u'2020, Christian Donnerer'
project = u"shellplot"
copyright = u"2020, Christian Donnerer"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '' # Is set by calling `setup.py docs`
version = "" # Is set by calling `setup.py docs`
# The full version, including alpha/beta/rc tags.
release = '' # Is set by calling `setup.py docs`
release = "" # Is set by calling `setup.py docs`

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -105,7 +114,7 @@

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']
exclude_patterns = ["_build"]

# The reST default role (used for this markup: `text`) to use for all documents.
# default_role = None
Expand All @@ -122,7 +131,7 @@
# show_authors = False

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# A list of ignored prefixes for module index sorting.
# modindex_common_prefix = []
Expand All @@ -135,15 +144,12 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'alabaster'
html_theme = "sphinx_rtd_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
'sidebar_width': '300px',
'page_width': '1200px'
}
# html_theme_options = {"sidebar_width": "300px", "page_width": "1200px"}

# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = []
Expand Down Expand Up @@ -172,7 +178,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]

# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
Expand Down Expand Up @@ -216,27 +222,30 @@
# html_file_suffix = None

# Output file base name for HTML help builder.
htmlhelp_basename = 'shellplot-doc'
htmlhelp_basename = "shellplot-doc"


# -- Options for LaTeX output --------------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
# 'preamble': '',
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
# 'preamble': '',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'user_guide.tex', u'shellplot Documentation',
u'Christian Donnerer', 'manual'),
(
"index",
"user_guide.tex",
u"shellplot Documentation",
u"Christian Donnerer",
"manual",
),
]

# The name of an image file (relative to this directory) to place at the top of
Expand All @@ -260,13 +269,13 @@
# latex_domain_indices = True

# -- External mapping ------------------------------------------------------------
python_version = '.'.join(map(str, sys.version_info[0:2]))
python_version = ".".join(map(str, sys.version_info[0:2]))
intersphinx_mapping = {
'sphinx': ('http://www.sphinx-doc.org/en/stable', None),
'python': ('https://docs.python.org/' + python_version, None),
'matplotlib': ('https://matplotlib.org', None),
'numpy': ('https://docs.scipy.org/doc/numpy', None),
'sklearn': ('http://scikit-learn.org/stable', None),
'pandas': ('http://pandas.pydata.org/pandas-docs/stable', None),
'scipy': ('https://docs.scipy.org/doc/scipy/reference', None),
"sphinx": ("http://www.sphinx-doc.org/en/stable", None),
"python": ("https://docs.python.org/" + python_version, None),
"matplotlib": ("https://matplotlib.org", None),
"numpy": ("https://docs.scipy.org/doc/numpy", None),
"sklearn": ("http://scikit-learn.org/stable", None),
"pandas": ("http://pandas.pydata.org/pandas-docs/stable", None),
"scipy": ("https://docs.scipy.org/doc/scipy/reference", None),
}

0 comments on commit 69dc824

Please sign in to comment.