@@ -508,7 +508,7 @@ visualization. Let's create a scatter plot using the `altair`
508
508
package with the ` waiting ` variable on the horizontal axis, the ` eruptions `
509
509
variable on the vertical axis, and the ` mark_point ` geometric object.
510
510
By default, ` altair ` draws only the outline of each point. If we would
511
- like to fill them in, we pass the argument ` filled=True ` to ` mark_point ` . In
511
+ like to fill them in, we pass the argument ` filled=True ` to ` mark_point ` . In
512
512
place of ` mark_point(filled=True) ` , we can also use ` mark_circle ` .
513
513
The result is shown in {numref}` faithful_scatter ` .
514
514
@@ -1225,9 +1225,9 @@ The plot in {numref}`islands_plot_sorted` is now a very effective
1225
1225
visualization for answering our original questions. Landmasses are organized by
1226
1226
their size, and continents are colored differently than other landmasses,
1227
1227
making it quite clear that continents are the largest seven landmasses.
1228
- We can make one more finishing touch in {numref}` islands_plot_titled ` : we will
1228
+ We can make one more finishing touch in {numref}` islands_plot_titled ` : we will
1229
1229
add a title to the chart by specifying ` title ` argument in the ` alt.Chart ` function.
1230
- Note that plot titles are not always required; usually plots appear as part
1230
+ Note that plot titles are not always required; usually plots appear as part
1231
1231
of other media (e.g., in a slide presentation, on a poster, in a paper) where
1232
1232
the title may be redundant with the surrounding context.
1233
1233
@@ -1353,10 +1353,10 @@ Note that
1353
1353
* vertical lines* are used to denote quantities on the * horizontal axis* ,
1354
1354
while * horizontal lines* are used to denote quantities on the * vertical axis* .
1355
1355
1356
- To add the dashed line on top of the histogram, we
1357
- ** add** the ` mark_rule ` chart to the ` morley_hist `
1356
+ To add the dashed line on top of the histogram, we
1357
+ ** add** the ` mark_rule ` chart to the ` morley_hist `
1358
1358
using the ` + ` operator.
1359
- Adding features to a plot using the ` + ` operator is known as * layering* in ` altair ` .
1359
+ Adding features to a plot using the ` + ` operator is known as * layering* in ` altair ` .
1360
1360
This is a very powerful feature of ` altair ` ; you
1361
1361
can continue to iterate on a single plot object, adding and refining
1362
1362
one layer at a time. If you stored your plot as a named object
@@ -1446,7 +1446,7 @@ To fix this issue we can convert the `Expt` variable into a `nominal`
1446
1446
(i.e., categorical) type variable by adding a suffix ` :N `
1447
1447
to the ` Expt ` variable. Adding the ` :N ` suffix ensures that ` altair `
1448
1448
will treat a variable as a categorical variable, and
1449
- hence use a discrete color map in visualizations.
1449
+ hence use a discrete color map in visualizations.
1450
1450
We also specify the ` stack=False ` argument in the ` y ` encoding so
1451
1451
that the bars are not stacked on top of each other.
1452
1452
@@ -1831,8 +1831,8 @@ perfectly re-created when loading and displaying, with the hope that the change
1831
1831
is not noticeable. * Lossless* formats, on the other hand, allow a perfect
1832
1832
display of the original image.
1833
1833
1834
- - * Common file types:*
1835
- - [ JPEG] ( https://en.wikipedia.org/wiki/JPEG ) (` .jpg ` , ` .jpeg ` ): lossy, usually used for photographs
1834
+ - * Common file types:*
1835
+ - [ JPEG] ( https://en.wikipedia.org/wiki/JPEG ) (` .jpg ` , ` .jpeg ` ): lossy, usually used for photographs
1836
1836
- [ PNG] ( https://en.wikipedia.org/wiki/Portable_Network_Graphics ) (` .png ` ): lossless, usually used for plots / line drawings
1837
1837
- [ BMP] ( https://en.wikipedia.org/wiki/BMP_file_format ) (` .bmp ` ): lossless, raw image data, no compression (rarely used)
1838
1838
- [ TIFF] ( https://en.wikipedia.org/wiki/TIFF ) (` .tif ` , ` .tiff ` ): typically lossless, no compression, used mostly in graphic arts, publishing
@@ -1845,8 +1845,8 @@ display of the original image.
1845
1845
objects (lines, surfaces, shapes, curves). When the computer displays the image, it
1846
1846
redraws all of the elements using their mathematical formulas.
1847
1847
1848
- - * Common file types:*
1849
- - [ SVG] ( https://en.wikipedia.org/wiki/Scalable_Vector_Graphics ) (` .svg ` ): general-purpose use
1848
+ - * Common file types:*
1849
+ - [ SVG] ( https://en.wikipedia.org/wiki/Scalable_Vector_Graphics ) (` .svg ` ): general-purpose use
1850
1850
- [ EPS] ( https://en.wikipedia.org/wiki/Encapsulated_PostScript ) (` .eps ` ), general-purpose use (rarely used)
1851
1851
- * Open-source software:* [ Inkscape] ( https://inkscape.org/ )
1852
1852
@@ -1875,7 +1875,7 @@ Let's learn how to save plot images to `.png` and `.svg` file formats using the
1875
1875
` faithful_scatter_labels ` scatter plot of the [ Old Faithful data set] ( https://www.stat.cmu.edu/~larry/all-of-statistics/=data/faithful.dat )
1876
1876
{cite: p }` faithfuldata ` that we created earlier, shown in {numref}` faithful_scatter_labels ` .
1877
1877
To save the plot to a file, we can use the ` save `
1878
- method. The ` save ` method takes the path to the filename where you would like to
1878
+ method. The ` save ` method takes the path to the filename where you would like to
1879
1879
save the file (e.g., ` img/filename.png ` to save a file named ` filename.png ` to the ` img ` directory).
1880
1880
The kind of image to save is specified by the file extension. For example, to
1881
1881
create a PNG image file, we specify that the file extension is ` .png ` . Below
@@ -1891,6 +1891,7 @@ faithful_scatter_labels.save("img/faithful_plot.svg")
1891
1891
```
1892
1892
1893
1893
``` {code-cell} ipython3
1894
+ :tags: [remove-cell]
1894
1895
import os
1895
1896
import numpy as np
1896
1897
png_size = np.round(os.path.getsize("img/faithful_plot.png")/(1024*1024), 2)
@@ -1916,9 +1917,9 @@ glue("svg_size", svg_size)
1916
1917
```
1917
1918
1918
1919
Take a look at the file sizes in {numref}` png-vs-svg-table `
1919
- Wow, that's quite a difference! In this case, the ` .png ` image is almost 4 times
1920
+ Wow, that's quite a difference! In this case, the ` .png ` image is almost 4 times
1920
1921
smaller than the ` .svg ` image. Since there are a decent number of points in the plot,
1921
- the vector graphics format image (` .svg ` ) is bigger than the raster image (` .png ` ), which
1922
+ the vector graphics format image (` .svg ` ) is bigger than the raster image (` .png ` ), which
1922
1923
just stores the image data itself.
1923
1924
In {numref}` png-vs-svg ` , we show what
1924
1925
the images look like when we zoom in to a rectangle with only 3 data points.
0 commit comments