|
49 | 49 | "source": [ |
50 | 50 | "## Why `altair`? Why not `matplotlib`?\n", |
51 | 51 | "\n", |
52 | | - "While `matplotlib` is a widely used and\n", |
53 | | - "quite flexible visualization library, the plots\n", |
54 | | - "programming does not follow a specific *grammar*.\n", |
55 | | - "\n", |
56 | | - "In this chapter, we have decided to present the `altair` library which\n", |
57 | | - "[facilitates the creation of highly informative charts](https://altair-viz.github.io/index.html)\n", |
| 52 | + "While `matplotlib` is a widely used and quite flexible\n", |
| 53 | + "visualization library, the plots programming is not\n", |
| 54 | + "as intuitive as with `altair`. Moreover, the `altair`\n", |
| 55 | + "[library](https://altair-viz.github.io/index.html)\n", |
| 56 | + "facilitates the creation of highly informative\n", |
| 57 | + "[interactive graphics](https://vega.github.io/vega-lite/)\n", |
58 | 58 | "from data stored in Pandas objects.\n", |
59 | | - "It is based on the grammar of interactive graphics of\n", |
60 | | - "[Vega-Lite](https://vega.github.io/vega-lite/),\n", |
61 | | - "which makes the programming both elegant and powerful.\n", |
62 | 59 | "\n", |
63 | 60 | "We will see different visualization concepts that can\n", |
64 | 61 | "be reproduced more or less easily with other libraries\n", |
|
468 | 465 | "lang": "en" |
469 | 466 | }, |
470 | 467 | "source": [ |
471 | | - "* The title and axis labels can be set:" |
| 468 | + "* The titles and the axis labels can be set:" |
472 | 469 | ] |
473 | 470 | }, |
474 | 471 | { |
|
483 | 480 | "alt.Chart(surveys_complete).mark_point().encode(\n", |
484 | 481 | " x=alt.X('hindfoot_length').title('Hindfoot length (mm)'),\n", |
485 | 482 | " y=alt.Y('weight').scale(type='log', base=2).title('Weight (g)'),\n", |
486 | | - " color=alt.Color('species_id'),\n", |
| 483 | + " color=alt.Color('species_id').title('Species ID'),\n", |
487 | 484 | " tooltip=['species_id'],\n", |
488 | 485 | ").configure_mark(\n", |
489 | 486 | " opacity=0.05,\n", |
|
916 | 913 | "source": [ |
917 | 914 | "`2`. Create the boxplot:\n", |
918 | 915 | "* The full species names on the X axis, with the label \"Species\"\n", |
919 | | - "* The noisy weights on the Y axis, with a logarithmic\n", |
| 916 | + "* The weights on the Y axis, with a logarithmic\n", |
920 | 917 | " scale in base 2 and with the label \"Weight (g)\"\n", |
921 | 918 | "* One color for each species identifier\n", |
922 | 919 | "* A title for the chart\n", |
|
0 commit comments