Kineo Styling Library
Project description
Kineo Styling Module
Library of Kineo Styling for the efficient plotting of graphs for presentations.
Importing anything
from kineo_styling import colors, styling, export
Colors Module
# Print all attributes of the colors module
print("The following attributes are available in the colors module:")
for i in dir(colors):
if "__" not in i:
print(f"{i}: {type(getattr(colors, i))}")
# You can see the colors via:
colors.show_colors()
Styling Module
Styling means, removing the background, enabling the kineo color palette and adjusting colors in accordance to dark/lightmode. Alos it removes the title. Since this title should be done on the presentations slides.
There are three things you can use inside the styling module: Example
import plotly.express as px
# Either pathing to lightmode or to dark mode
@styling.patch_to_light_mode
def example_bar_chart():
df = px.data.iris()
fig = px.bar(df, x="sepal_width", y="sepal_length", color="species", barmode="group")
return fig
# Or you can use the dark mode
@styling.patch_to_dark_mode
def example_line_chart():
df = px.data.gapminder().query("continent=='Oceania'")
fig = px.line(df, x="year", y="lifeExp", color='country')
return fig
fig1 = example_bar_chart()
fig1.show()
fig2 = example_line_chart()
fig2.show()
Styling Module
Styling means, removing the background, enabling the kineo color palette and adjusting colors in accordance to dark/lightmode. Alos it removes the title. Since this title should be done on the presentations slides.
There are three things you can use inside the styling module: Example for Decorators
import plotly.express as px
# Either pathing to lightmode or to dark mode
@styling.patch_to_light_mode
def example_bar_chart():
df = px.data.iris()
fig = px.bar(df, x="sepal_width", y="sepal_length", color="species", barmode="group")
return fig
# Or you can use the dark mode
@styling.patch_to_dark_mode
def example_line_chart():
df = px.data.gapminder().query("continent=='Oceania'")
fig = px.line(df, x="year", y="lifeExp", color='country')
return fig
fig1 = example_bar_chart()
fig1.show()
fig2 = example_line_chart()
fig2.show()
Example for styling function
import plotly.express as px
def example_bar_chart():
df = px.data.tips()
fig = px.box(df, x="day", y="total_bill", color="smoker", points="all")
return fig
fig = example_bar_chart()
fig = styling.style_fig_for_presentation(
fig=fig, # The figure to use
update_layout_kwargs={}, # any kwargs that you would pass to fig.update_layout
update_traces_kwargs={}, # any kwargs that you would pass to fig.update_traces
patch_colors=True, # Whether to patch colors to the kineo color palette
dark_mode=True, # Whether to patch to dark mode
)
fig.show()
Export Module
This module only contains function to export figures in Kineo styles
import plotly.express as px
import pandas as pd
data = [1,2,3,4,5,6,7,8,9]
df = pd.DataFrame(dict(
linear=data,
inclusive=data,
exclusive=data
)).melt(var_name="quartilemethod")
fig = px.box(df, y="value", facet_col="quartilemethod", color="quartilemethod",
boxmode="overlay", points='all')
fig.update_traces(quartilemethod="linear", jitter=0, col=1)
fig.update_traces(quartilemethod="inclusive", jitter=0, col=2)
fig.update_traces(quartilemethod="exclusive", jitter=0, col=3)
export.export_figure_as_png(
fig=fig, # The figure to use
output_path="example_plot_dark.png", # The output path for the image
update_layout_kwargs={}, # any kwargs that you would pass to fig.update_layout
update_traces_kwargs={}, # any kwargs that you would pass to fig.update_traces
patch_colors=True, # Whether to patch colors to the kineo color palette
dark_mode=True, # Whether to patch to dark mode
)
# export.export_figure_as_png_dark_mode(fig, "example_plot_dark.png")
export.export_figure_as_png_light_mode(fig, "example_plot_light.png")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kineo_styling-0.0.1-py3-none-any.whl.
File metadata
- Download URL: kineo_styling-0.0.1-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83a4130089667f52f12f101dad8d012b780a8a53f2bbc899a0339c7e4ebf9dd1
|
|
| MD5 |
c7c4b3a43eb1e642f414f87ee43542fc
|
|
| BLAKE2b-256 |
34a658ffb4e41439db078a4a04a0482e7b34c3a53aaab9a2761ad28b8daeba40
|