From 4b66b5623fcd42004af8878420664cd021b663d5 Mon Sep 17 00:00:00 2001 From: Paulo Eduardo Neves Date: Mon, 13 Dec 2021 17:54:20 -0300 Subject: [PATCH] Initial style for Altair charts --- altair.py | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 altair.py diff --git a/altair.py b/altair.py new file mode 100644 index 0000000..524331d --- /dev/null +++ b/altair.py @@ -0,0 +1,132 @@ +import altair as alt + +def charp_theme(): + markColor = "#1696d2" + axisColor = "#000000" + backgroundColor = "#FFFFFF" + font = "Lato" + labelFont = "Lato" + sourceFont = "Lato" + gridColor = "#DEDDDD" + main_palette = ["#1696d2", + "#d2d2d2", + "#000000", + "#fdbf11", + "#ec008b", + "#55b748", + "#5c5859", + "#db2b27", + ] + sequential_palette = ["#cfe8f3", + "#a2d4ec", + "#73bfe2", + "#46abdb", + "#1696d2", + "#12719e", + ] + return { + "width": 685, + "height": 380, +# "autosize": "fit", + "config": { + "title": { + "anchor": "start", + "fontSize": 18, + "font": font, + "fontColor": "#000000" + }, + "axisX": { + "domain": True, + "domainColor": axisColor, + "domainWidth": 1, + "grid": False, + "labelFontSize": 12, + "labelFont": labelFont, + "labelAngle": 0, + "tickColor": axisColor, + "tickSize": 5, + "titleFontSize": 12, + "titlePadding": 10, + "titleFont": font, + "title": "", + }, + "axisY": { + "domain": False, + "grid": True, + "gridColor": gridColor, + "gridWidth": 1, + "labelFontSize": 12, + "labelFont": labelFont, + "labelPadding": 8, + "ticks": False, + "titleFontSize": 12, + "titlePadding": 10, + "titleFont": font, + "titleAngle": 0, + "titleY": -10, + "titleX": 18, + }, + "background": backgroundColor, + "legend": { + "labelFontSize": 12, + "labelFont": labelFont, + "symbolSize": 100, + "symbolType": "square", + "titleFontSize": 12, + "titlePadding": 10, + "titleFont": font, + "title": "", + "orient": "top-left", + "offset": 0, + }, + "view": { + "stroke": "transparent", + }, + "range": { + "category": main_palette, + "diverging": sequential_palette, + }, + "area": { + "fill": markColor, + }, + "line": { + "color": markColor, + "stroke": markColor, + "strokewidth": 5, + }, + "trail": { + "color": markColor, + "stroke": markColor, + "strokeWidth": 0, + "size": 1, + }, + "path": { + "stroke": markColor, + "strokeWidth": 0.5, + }, + "point": { + "filled": True, + }, + "text": { + "font": sourceFont, + "color": markColor, + "fontSize": 11, + "align": "right", + "fontWeight": 400, + "size": 11, + }, + "bar": { + "size": 40, + "binSpacing": 1, + "continuousBandSize": 30, + "discreteBandSize": 30, + "fill": markColor, + "stroke": False, + }, + }, + } + + +alt.themes.register("charp", charp_theme) +alt.themes.enable("charp") +