A deceptively simple plotting library for Streamlit

Overview

🍅 Plost

A deceptively simple plotting library for Streamlit.

Because you've been writing plots wrong all this time.

Open in Streamlit

Getting started

pip install plost

Basics

Plost makes it easy to build common plots using the Vega-Lite library but without having to delve into Vega-Lite specs (unless you're doing something tricky), and without having to melt your DataFrame from long format to wide format (the bane of most Vega-Lite plots!)

For example, let's say you have a "long-format" table like this:

time stock_name stock_value
... stock1 1
... stock2 2
... stock1 100
... stock2 200

Then you can draw a line chart by simply calling line_chart() with some column names:

import plost

plost.line_chart(
  my_dataframe,
  x='time',  # The name of the column to use for the x axis.
  y='stock_value',  # The name of the column to use for the data itself.
  color='stock_name', # The name of the column to use for the line colors.
)

Simple enough! But what if you instead have a "wide-format" table like this, which is super common in reality:

time stock1 stock2
... 1 100
... 2 200

Normally you'd have to melt() the table with Pandas first or create a complex Vega-Lite layered plot. But with Plost, you can just specify what you're trying to accomplish and it will melt the data internally for you:

import plost

plost.line_chart(
  my_dataframe,
  x='time',
  y=('stock1', 'stock2'),  # 👈 This is magic!
)

Ok, now let's add a mini-map to make panning/zooming even easier:

import plost

plost.line_chart(
  my_dataframe,
  x='time',
  y=('stock1', 'stock2'),
  pan_zoom='minimap',  # 👈 This is magic!
)

But we're just scratching the surface. Basically the idea is that Plost allows you to make beautiful Vega-Lite-driven charts for your most common needs, without having to learn about the powerful yet complex language behind Vega-Lite.

Check out the the sample app / docs for a taste of other amazing things you can do!

Juicy examples

Check out the sample app!

Documentation

This is in the sample app too!

Comments
  • Bug Report Bar Chart

    Bug Report Bar Chart

    Jo @tvst ,

    think i found a bug. What i tried is:

    plost.bar_chart(
        data=datasets['stocks'],
        bar='company',
        value=['q2', 'q3'],
        direction='horizontal'
    )
    

    But values of q3 get stacked on top of q2 even though the values of q3 should be plotted as part of q2 as the value of q2 is higher. For vertical it works as expected.

    Could you double check and in case fix that?

    Best regards Chris

    opened by ChrisDelClea 4
  • how tricky is it to implement two-way communication between plots and python?

    how tricky is it to implement two-way communication between plots and python?

    Thank you for this great library :clap: ! I'm wondering how difficult it is to add two-way communication between chart objects and streamlit in order to update streamlit applications based upon click events, selections, etc... on charts. From some preliminary digging it seems like it's pretty non-trivial but want to be sure I'm not missing something obvious. I am interested in working on this but it would be great to get some understanding of the level of challenge first.

    opened by chrishokamp 3
  • Over resource limits on Streamlit Cloud

    Over resource limits on Streamlit Cloud

    opened by ericgarza70 1
  • Over resource limits on Streamlit Cloud

    Over resource limits on Streamlit Cloud

    opened by themotu 1
  • Over resource limits on Streamlit Cloud

    Over resource limits on Streamlit Cloud

    opened by oezdemir 1
  • Replaces tomato emoji with GitHub flavored markdown

    Replaces tomato emoji with GitHub flavored markdown

    The tomato emoji in the README breaks installation on Windows via setup.py:

    with open("README.md", "r") as fh:
        long_description = fh.read()
    
    PS C:\Users\sneha\Desktop> pip install plost --no-cache-dir
    Collecting plost
      Downloading Plost-0.2.1.tar.gz (12 kB)
        ERROR: Command errored out with exit status 1:
         command: 'c:\users\sneha\appdata\local\programs\python\python38\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\sneha\\AppData\\Local\\Temp\\pip-install-6oqzx1bp\\plost_026235d7f64b4ef5854eed7dffc9ce84\\setup.py'"'"'; __file__='"'"'C:\\Users\\sneha\\AppData\\Local\\Temp\\pip-install-6oqzx1bp\\plost_026235d7f64b4ef5854eed7dffc9ce84\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\sneha\AppData\Local\Temp\pip-pip-egg-info-qt103lso'
             cwd: C:\Users\sneha\AppData\Local\Temp\pip-install-6oqzx1bp\plost_026235d7f64b4ef5854eed7dffc9ce84\
        Complete output (7 lines):
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "C:\Users\sneha\AppData\Local\Temp\pip-install-6oqzx1bp\plost_026235d7f64b4ef5854eed7dffc9ce84\setup.py", line 4, in <module>
            long_description = fh.read()
          File "c:\users\sneha\appdata\local\programs\python\python38\lib\encodings\cp1252.py", line 23, in decode
            return codecs.charmap_decode(input,self.errors,decoding_table)[0]
        UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 4: character maps to <undefined>
    

    Replaces the emoji with GitHub flavored markdown :tomato: so that the emoji is correctly rendered on GitHub + the README is parsed on Windows.

    opened by snehankekre 0
  • color attribute not supported

    color attribute not supported

    In the current version of plost 0.2.5, color attribute of every chart type is not supported.

    Looking in the code, there seem to be a lack of passing through the value of the color argument.

    One easy fix is to replace every

    spec = D(
            mark=D(type='circle', tooltip=True),
            encoding=D(
                x=_clean_encoding(data, x),
                y=y_enc,
                color=color_enc,
                size=_clean_encoding(data, size, legend=legend),
                opacity=_clean_encoding(data, opacity, legend=legend),
            ),
            selection=_get_selection(pan_zoom),
        )
    

    by

    spec = D(
            mark=D(type='circle', tooltip=True),
            encoding=D(
                x=_clean_encoding(data, x),
                y=y_enc,
                color=_clean_encoding(data, color),
                size=_clean_encoding(data, size, legend=legend),
                opacity=_clean_encoding(data, opacity, legend=legend),
            ),
            selection=_get_selection(pan_zoom),
        )
    

    The change is in the line color=color_enc to color=_clean_encoding(data, color).

    opened by farresti 0
  • Feature request

    Feature request

    Hi @tvst ,

    could you please add an easier way to pass individual color values? Why I am asking is, i have bar_chart and i want to add a color for each value in the bar chart:

    plost.bar_chart(
    data=df, 
    bar="epic", 
    value=["time_1", "time_2", "time_3"],
    direction="horizontal", 
    colors=["#0001","#0002","#0003"]
    )
    

    So each bar has the three times in a different color for all unquie values in epic. Also i saw you used the param legend=None but never passed any value, how could i use it to specifiy the x-axis value?

    Best Regards Chris

    opened by ChrisDelClea 0
  • Certain legends are black-on-dark in dark mode

    Certain legends are black-on-dark in dark mode

    Hi, not a user, just a passerby, but I noticed that on dark mode of the demo site some of the legends/labels are black (whereas some are, correctly, white).

    For example, the q2 and q3 in the below screenshot (whereas the individual bar legends are correct).

    image

    opened by Qix- 1
Owner
Thiago Teixeira
co-founder @ Streamlit
Thiago Teixeira
Simple plotting for Python. Python wrapper for D3xter - render charts in the browser with simple Python syntax.

PyDexter Simple plotting for Python. Python wrapper for D3xter - render charts in the browser with simple Python syntax. Setup $ pip install PyDexter

D3xter 31 Mar 6, 2021
Plotting library for IPython/Jupyter notebooks

bqplot 2-D plotting library for Project Jupyter Introduction bqplot is a 2-D visualization system for Jupyter, based on the constructs of the Grammar

null 3.4k Dec 29, 2022
An intuitive library to add plotting functionality to scikit-learn objects.

Welcome to Scikit-plot Single line functions for detailed visualizations The quickest and easiest way to go from analysis... ...to this. Scikit-plot i

Reiichiro Nakano 2.3k Dec 31, 2022
🎨 Python3 binding for `@AntV/G2Plot` Plotting Library .

PyG2Plot ?? Python3 binding for @AntV/G2Plot which an interactive and responsive charting library. Based on the grammar of graphics, you can easily ma

hustcc 990 Jan 5, 2023
NorthPitch is a python soccer plotting library that sits on top of Matplotlib

NorthPitch is a python soccer plotting library that sits on top of Matplotlib.

Devin Pleuler 30 Feb 22, 2022
🎨 Python Echarts Plotting Library

pyecharts Python ❤️ ECharts = pyecharts English README ?? 简介 Apache ECharts (incubating) 是一个由百度开源的数据可视化,凭借着良好的交互性,精巧的图表设计,得到了众多开发者的认可。而 Python 是一门富有表达

pyecharts 13.1k Jan 3, 2023
Plotting library for IPython/Jupyter notebooks

bqplot 2-D plotting library for Project Jupyter Introduction bqplot is a 2-D visualization system for Jupyter, based on the constructs of the Grammar

null 3.4k Dec 30, 2022
:small_red_triangle: Ternary plotting library for python with matplotlib

python-ternary This is a plotting library for use with matplotlib to make ternary plots plots in the two dimensional simplex projected onto a two dime

Marc 611 Dec 29, 2022
An open-source plotting library for statistical data.

Lets-Plot Lets-Plot is an open-source plotting library for statistical data. It is implemented using the Kotlin programming language. The design of Le

JetBrains 820 Jan 6, 2023
🎨 Python Echarts Plotting Library

pyecharts Python ❤️ ECharts = pyecharts English README ?? 简介 Apache ECharts (incubating) 是一个由百度开源的数据可视化,凭借着良好的交互性,精巧的图表设计,得到了众多开发者的认可。而 Python 是一门富有表达

pyecharts 10.6k Feb 18, 2021
Plotting library for IPython/Jupyter notebooks

bqplot 2-D plotting library for Project Jupyter Introduction bqplot is a 2-D visualization system for Jupyter, based on the constructs of the Grammar

null 3k Feb 18, 2021
:small_red_triangle: Ternary plotting library for python with matplotlib

python-ternary This is a plotting library for use with matplotlib to make ternary plots plots in the two dimensional simplex projected onto a two dime

Marc 391 Feb 17, 2021
An open-source plotting library for statistical data.

Lets-Plot Lets-Plot is an open-source plotting library for statistical data. It is implemented using the Kotlin programming language. The design of Le

JetBrains 509 Feb 17, 2021
A Python library for plotting hockey rinks with Matplotlib.

Hockey Rink A Python library for plotting hockey rinks with Matplotlib. Installation pip install hockey_rink Current Rinks The following shows the cus

null 24 Jan 2, 2023
termplotlib is a Python library for all your terminal plotting needs.

termplotlib termplotlib is a Python library for all your terminal plotting needs. It aims to work like matplotlib. Line plots For line plots, termplot

Nico Schlömer 553 Dec 30, 2022
MPL Plotter is a Matplotlib based Python plotting library built with the goal of delivering publication-quality plots concisely.

MPL Plotter is a Matplotlib based Python plotting library built with the goal of delivering publication-quality plots concisely.

Antonio López Rivera 162 Nov 11, 2022
This is a Cross-Platform Plot Manager for Chia Plotting that is simple, easy-to-use, and reliable.

Swar's Chia Plot Manager A plot manager for Chia plotting: https://www.chia.net/ Development Version: v0.0.1 This is a cross-platform Chia Plot Manage

Swar Patel 1.3k Dec 13, 2022
A simple code for plotting figure, colorbar, and cropping with python

Python Plotting Tools This repository provides a python code to generate figures (e.g., curves and barcharts) that can be used in the paper to show th

Guanying Chen 134 Jan 2, 2023
Streamlit component for Let's-Plot visualization library

streamlit-letsplot This is a work-in-progress, providing a convenience function to plot charts from the Lets-Plot visualization library. Example usage

Randy Zwitch 9 Nov 3, 2022