Skip to content

Commit

Permalink
Initial style for Altair charts
Browse files Browse the repository at this point in the history
  • Loading branch information
paulobndes committed Dec 13, 2021
1 parent 51c9bec commit 4b66b56
Showing 1 changed file with 132 additions and 0 deletions.
132 changes: 132 additions & 0 deletions altair.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 4b66b56

Please sign in to comment.