Altair VS matplotlib

Compare Altair vs matplotlib and see what are their differences.

Altair

Declarative statistical visualization library for Python (by altair-viz)
Our great sponsors
  • Scout APM - Less time debugging, more time building
  • SonarLint - Deliver Cleaner and Safer Code - Right in Your IDE of Choice!
  • SaaSHub - Software Alternatives and Reviews
Altair matplotlib
26 18
7,493 15,468
1.4% 1.4%
8.1 10.0
about 23 hours ago 6 days ago
Python Python
BSD 3-clause "New" or "Revised" License Python License 2.0
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

Altair

Posts with mentions or reviews of Altair. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2022-05-09.

matplotlib

Posts with mentions or reviews of matplotlib. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2022-03-28.
  • How to get a matplotlib Axes instance to plot to?
    1 project | reddit.com/r/codehunter | 10 Apr 2022
    I need to make a candlestick chart (something like this) using some stock data. For this I want to use the function matplotlib.finance.candlestick(). To this function I need to supply quotes and "an Axes instance to plot to". I created some sample quotes as follows:
  • Python Libraries, modules and packages.
    1 project | dev.to | 4 Apr 2022
    Matplotlib library is a standard library for generating data visualizations in Python. It supports building basic two-dimensional graphs as well as more complex animated and interactive visualizations.
  • How to make sure a python program runs on a computer that might not have internet connection to download the external libraries used?
    6 projects | reddit.com/r/learnpython | 28 Mar 2022
    The thing is, you will also need to go get the wheels (or *.tar.gz sources) for all of the dependencies of your packages as well! Over in matplotlib's setup.py you can find the following:
  • Matplotlib just nuked all of my styles because they now hate abbreviated HTML colors.
    2 projects | reddit.com/r/learnpython | 14 Feb 2022
    GitHub history for rcsetup.py
    2 projects | reddit.com/r/learnpython | 14 Feb 2022
    This commit. You can get that by clicking "View Git Blame" on line 307.
  • Reducing the Size of Large PDFs
    2 projects | news.ycombinator.com | 31 Jan 2022
    Oh didn't know about the improved type 42 font support in the new matplotlib! That's good to know and I should check it out.

    And good point, the PGF works just as well (results should be identical), but since all the plot information has to be compiled by latex, it ends up ballooning the compilation time of the tex doc and the matplotlib PGF page suggests that you can run into memory issues as well. I was doing this for a thesis with 50+ plots and so still wanted compilation to be fast.

    I've suggested this as an improvement to matplotlib, but unlikely to be merged since maybe it's a bit hacky (although it's very similar to what Inkscape's export to LaTeX option does): https://github.com/matplotlib/matplotlib/issues/22297 (the backend file can be found here: https://github.com/matplotlib/matplotlib/files/7921801/backe...)

    And the gs script is below:

      #!/bin/bash
  • Looking for help formatting a line graph
    1 project | reddit.com/r/libreoffice | 10 Dec 2021
    matplotlib + their User's Guide.
  • Problem with surface plot color and legend
    1 project | reddit.com/r/learnpython | 24 Nov 2021
    # https://old.reddit.com/r/learnpython/comments/r1etmt/problem_with_surface_plot_color_and_legend/ # AmericaRL_03.py # Comparação entre random walk e difusão em 1d import numpy as np import matplotlib.pyplot as plt M = 100000 # Número de walkers L = 100 # Tamanho da malha # A cada intervalo de tempo, mover o walker e propagar a difusão p = 0.1 # Probabilidade de andar pinv = 1.0 - p nsteps = 2001 # Número de intervalos de tempo # Iniciando as concentrações c = np.zeros((2, 2 * L + 1, 2 * L + 1)) i0 = 0 i1 = 1 c[:, L, L] = M # c[:,L,L] corresponde a (x,y) = (0,0) edgesdiff = np.array(range(-L - 1, L + 1)) - 0.5 xc = 0.5 * (edgesdiff[:-1] + edgesdiff[1:]) xx, yy = np.meshgrid(xc, xc) D = p noutput = 100 for it in range(nsteps): # Executar a etapa na equação de difusão for ix in range(1, len(c[0]) - 1): for iy in range(1, len(c[0]) - 1): # Usar i0 e gerar i1 c[i1, ix, iy] = c[i0, ix, iy] + D * ( c[i0, ix - 1, iy] + c[i0, ix + 1, iy] - 4 * c[i0, ix, iy] + c[i0, ix, iy - 1] + c[i0, ix, iy + 1] ) # Inverter i0 e i1 ii = i1 i1 = i0 i0 = ii # Plotar as concentrações if np.mod(it, noutput) == 0: fig = plt.figure() ax = fig.add_subplot(111, projection="3d") # ax.cla() diff = ax.plot_surface(xx, yy, c[0, :, :], cmap="Reds", label="Difusão") plt.title("Tempo = {}, M = {}, p = {}".format(it, M, p)) ax.set_xlabel("Distância percorrida (x)") ax.set_ylabel("Distância percorrida (y)") ax.set_zlabel("Concentração") # ax.legend() fails getting proper label key color in 3D plots # # AttributeError missing _facecolors2d and _edgecolors2d are raised # in 3D projection method get_facecolor() used by legend handler # # Is open issue since 2015 # https://github.com/matplotlib/matplotlib/issues/4067 if False: # OP's way: Set values manually to keep legend() quiet diff._facecolors2d = diff._facecolor3d diff._edgecolors2d = diff._edgecolor3d ax.legend() # But then problems with legend() getting proper legend key color # default (blue) is used instead of a value from set cmap (Reds) else: # DIFFERENT FIX: Draw legend key and legend label manually # # First get suitable cmap color (instead blue default) # https://stackoverflow.com/a/25408562 from matplotlib.cm import get_cmap cmap = get_cmap('Reds') my_red_rgba = cmap(0.5) # e.g. a color in middle of range (0..1) # Then insert own artist for legend key and legend label # https://matplotlib.org/stable/tutorials/intermediate/legend_guide.html import matplotlib.patches as mpatches red_patch = mpatches.Patch(color=my_red_rgba, label='Difusão') ax.legend(handles=[red_patch]) # plt.show() plt.savefig('tempo_{}.png'.format(it),dpi = 600) plt.pause(0.001) ax.cla() # is nicer placed here instead above
  • Python 3.8, 3.9 or 3.10 for new projects?
    3 projects | reddit.com/r/Python | 30 Oct 2021
    matplotlib supports 3.10 since May
  • Top 10 Python Libraries for Machine Learning
    14 projects | dev.to | 9 Sep 2021
    Website: https://matplotlib.org/ Github Repository: https://github.com/matplotlib/matplotlib Developed By: Micheal Droettboom, Community Primary purpose: Data Visualization

What are some alternatives?

When comparing Altair and matplotlib you can also consider the following projects:

plotly - The interactive graphing library for Python (includes Plotly Express) :sparkles:

PyQtGraph - Fast data visualization and GUI tools for scientific / engineering applications

bokeh - Interactive Data Visualization in the browser, from Python

seaborn - Statistical data visualization in Python

pygal - PYthon svg GrAph plotting Library

bqplot - Plotting library for IPython/Jupyter notebooks

plotnine - A grammar of graphics for Python

ggplot - ggplot port for python

VisPy - Main repository for Vispy