|
1 | 1 | """ |
2 | | -Displays the difference between interpolation = 'none' and |
| 2 | +Displays the difference between interpolation = 'none' and |
3 | 3 | interpolation = 'nearest'. |
4 | 4 |
|
5 | | -Interpolation = 'none' and interpolation = 'nearest' are equivalent when |
6 | | -converting a figure to an image file, such as a PNG. |
7 | | -Interpolation = 'none' and interpolation = 'nearest' behave quite |
8 | | -differently, however, when converting a figure to a vector graphics file, |
9 | | -such as a PDF. As shown, Interpolation = 'none' works well when a big |
10 | | -image is scaled down, while interpolation = 'nearest' works well when a |
| 5 | +Interpolation = 'none' and interpolation = 'nearest' are equivalent when |
| 6 | +converting a figure to an image file, such as a PNG. |
| 7 | +Interpolation = 'none' and interpolation = 'nearest' behave quite |
| 8 | +differently, however, when converting a figure to a vector graphics file, |
| 9 | +such as a PDF. As shown, Interpolation = 'none' works well when a big |
| 10 | +image is scaled down, while interpolation = 'nearest' works well when a |
11 | 11 | small image is blown up. |
12 | 12 | """ |
13 | 13 |
|
|
41 | 41 | fig.text(0.383, 0.90, "Interpolation = 'none'", ha = 'center') |
42 | 42 | fig.text(0.75, 0.90, "Interpolation = 'nearest'", ha = 'center') |
43 | 43 |
|
44 | | -#If you were going to run this example on your local machine, you |
45 | | -#would save the figure as a PNG, save the same figure as a PDF, and |
| 44 | +#If you were going to run this example on your local machine, you |
| 45 | +#would save the figure as a PNG, save the same figure as a PDF, and |
46 | 46 | #then compare them. The following code would suffice. |
47 | | -txt = fig1.text(0.452, 0.95, 'Saved as a PNG', fontsize = 18) |
| 47 | +txt = fig.text(0.452, 0.95, 'Saved as a PNG', fontsize = 18) |
48 | 48 | # plt.savefig('None_vs_nearest-png.png') |
49 | 49 | # txt.set_text('Saved as a PDF') |
50 | 50 | # plt.savefig('None_vs_nearest-pdf.pdf') |
51 | 51 |
|
52 | 52 | #Here, however, we need to display the PDF on a webpage, which means |
53 | | -#the PDF must be converted into an image. For the purposes of this |
54 | | -#example, the 'Nearest_vs_none-pdf.pdf' has been pre-converted into |
| 53 | +#the PDF must be converted into an image. For the purposes of this |
| 54 | +#example, the 'Nearest_vs_none-pdf.pdf' has been pre-converted into |
55 | 55 | #'Nearest_vs_none-pdf.png' at 80 dpi. We simply need to load and |
56 | 56 | #display it. |
57 | 57 | pdf_im_path = cbook.get_sample_data('None_vs_nearest-pdf.png') |
|
0 commit comments