Skip to main content

This is a lib to help you plot your fency graphs from plotly in github while using Google Colab notebook.

Project description

Image of gitly

gitly: Showing plotly graphs in github

This is a home made lib to help you plot your fency graphs from plotly in github while using Google Colab notebook.

The problem: Nbviewer from Github is static!

The problem is that all fency engines that you use on notebooks doesn't run in static viewers, of course there's a lot of ways to generate static images in this libraries. But I use Google Colab by a lot in my classes and I would like to have a easy way to switch betweern dinamic plots and statics plots (to commit and share nice plots in github). So I implement this very simple implementation.

Easy switch between colab and git "renderers"

Just change from dinamic to static using:

from gitly.colab.plot import GitlyPlotter

# Instantiate the object using 'github' or 'git' for static plots
# or 'colab' for default dinamic Plotly plots
gitly = GitlyPlotter('github')

Now just pass the figure from plotly to gitly.show( fig ) and it's done!!!

import plotly.express as px

fig = px.scatter_3d( df, title="Random data")
gitly.show( fig )

Now you can commit all your fency plots in github! Congratz!

Can I use both in the same Colab notebook? Sure you can!

Just use gitly.config_render('colab') to switch back in the cell and renderer with default plot from Plotly.

Example here!

You can check that some plots you can see (used "github" view) and others that is used the standard Plotly Engine you only can see if you run this notebook in Google colab.

Simple Example

Instalation

This lib is intended to be used only on Google Colab notebooks.

Open a cell and run the following code:

!pip install gitly==1.0.1

Features

This features are only for static plots.

Change the defaults

You are able to set a default values for hight, width and scale for all your plots.

gitly.config_render('git', default_height = 600, default_width = 1000) # set default values for all gitly.show()

fig = px.scatter_3d( df, title="Random data")
gitly.show( fig )

Change the scale where ever you want, and all plots after will scale up or down:

gitly.config_render('git', scale = 0.5) # set default scale for all gitly.show()

fig = px.scatter_3d( df, title="Random data")
gitly.show( fig )

Apply change for a specific plot

Or apply an specific change only to one plot while calling .show() with more arguments:

fig = px.scatter_3d( df, title="Random data")
gitly.show( fig, height = 333, width = 777, scale = 1.5 ) # this change will be applied only for this plot

For more, check this example

License

MIT

Created without pretensions by Tiago Sanches da Silva.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gitly-1.1.2.tar.gz (4.4 kB view details)

Uploaded Source

File details

Details for the file gitly-1.1.2.tar.gz.

File metadata

  • Download URL: gitly-1.1.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.1 CPython/3.9.0

File hashes

Hashes for gitly-1.1.2.tar.gz
Algorithm Hash digest
SHA256 b382ade9f4ba59be93e73ef0144aca99026c811c6db8ab90489a31c701662902
MD5 1b09dcb034f0765c184f8a60c73e3c07
BLAKE2b-256 0e656e655c5f9091fe9ac0974c63a9feb84cfb320fe04df62ab353a5be7599cf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page