Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

João Palmeiro
João Palmeiro

Posted on

     

A chart walks into a bar: Altair vs. leather

In this blog post series, we're going to compare two Data Visualization packages in the Python landscape. We will create a bar chart from dummy data, based onthis example available in the Altair documentation, with each package. Furthermore, we will try to follow the most straightforward implementation to compare the two APIs/charts from their defaults.

For this first installment, let's create a bar chart usingAltair and thenleather. The dataset looks like this:

importpandasaspdsource=pd.DataFrame({"a":["A","B","C","D","E","F","G","H","I"],"b":[28,55,43,91,81,53,19,87,52],})
Enter fullscreen modeExit fullscreen mode

From thesource above, we can define a bar chart in Altair via the following snippet:

importaltairasaltalt.Chart(source).mark_bar().encode(x="a",y="b")
Enter fullscreen modeExit fullscreen mode

When we run the snippet above, we get the result below:

Bar chart created with Altair

Now, using leather, we get a similar bar chart as follows:

importleatherchart=leather.Chart()# We cannot use a pandas DataFrame directly.chart.add_columns(data=source.to_records(index=False).tolist())chart.to_svg()
Enter fullscreen modeExit fullscreen mode

Bar chart created with leather

Comparing the two (default) outputs, we can highlight a number of differences:

  • The default width is larger with leather. As a result, the bars are also wider.
  • In leather, the bars are red (#e41a1c), compared to blue in Altair.
  • The bar chart created with leather does not show titles for the axes, unlike Altair.
  • There is no axis line on the Y-axis in leather. On the X-axis, the labels are not rotated (0°).
  • In Altair, there are only horizontal gridlines. In the case of leather, there are horizontal and vertical ones.
  • The default fonts are different. In leather,Monaco is used.
  • The background colors are also different. In Altair, the background color is white, while in leather, it is a (very) light gray (#f9f9f9).

On the other hand, for the Y-axis, both charts present a scale with the same domain, ending in anice round value (100). However, the number of ticks is different.

Finally, if you have any questions or suggestions, feel free to leave a comment below!

Top comments(2)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
loren_john profile image
Jorde Calf
Marketing Manager
  • Location
    united Kingdom
  • Joined

I loved this comparison of Altair and leather for data visualization in Python! The detailed analysis of each package's default styles is very insightful. Great job showcasing the unique features of both tools!

CollapseExpand
 
excellent_leathershop_ae profile image
Excellent Leather shop
Our jackets are made from original leather and these replica jackets are produced following thorough research. You can find dozens, maybe hundreds of stores online selling leather goods made here.
  • Location
    USA
  • Joined

The reading material you're sharing is advantageous to us. Feel Free to Serve mywebsite.

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

What is the most loyal tool of a programmer? Git, because of its COMMITment!
  • Location
    Lisbon, Portugal
  • Work
    Data Visualization Engineer at Feedzai
  • Joined

More fromJoão Palmeiro

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp