Show More
@@ -100,7 +100,7 b" plt.fill_between(xint, 0, yint, facecolor='gray', alpha=0.4)" | |||||
100 | plt.text(0.5 * (a + b), 30,r"$\int_a^b f(x)dx$", horizontalalignment='center', fontsize=20); |
|
100 | plt.text(0.5 * (a + b), 30,r"$\int_a^b f(x)dx$", horizontalalignment='center', fontsize=20); | |
101 |
|
101 | |||
102 | # Out[3]: |
|
102 | # Out[3]: | |
103 |
# image file: tests/ipynbref/IntroNumPy |
|
103 | # image file: tests/ipynbref/IntroNumPy_orig_files/IntroNumPy_orig_fig_00.svg | |
104 |
|
104 | |||
105 | # Compute the integral both at high accuracy and with the trapezoid approximation |
|
105 | # Compute the integral both at high accuracy and with the trapezoid approximation | |
106 |
|
106 | |||
@@ -436,7 +436,7 b" print 'The sum of elements along the columns is :', arr.sum(axis=0)" | |||||
436 | # The sum of elements along the rows is : [ 6 22] |
|
436 | # The sum of elements along the rows is : [ 6 22] | |
437 | # The sum of elements along the columns is : [ 4 6 8 10] |
|
437 | # The sum of elements along the columns is : [ 4 6 8 10] | |
438 | # |
|
438 | # | |
439 |
# As you can see in this example, the value of the `axis` parameter is the dimension which will be *consumed* once the operation has been carried out. This is why to sum along the rows we use `axis=0`. |
|
439 | # As you can see in this example, the value of the `axis` parameter is the dimension which will be *consumed* once the operation has been carried out. This is why to sum along the rows we use `axis=0`. | |
440 | # |
|
440 | # | |
441 | # This can be easily illustrated with an example that has more dimensions; we create an array with 4 dimensions and shape `(3,4,5,6)` and sum along the axis number 2 (i.e. the *third* axis, since in Python all counts are 0-based). That consumes the dimension whose length was 5, leaving us with a new array that has shape `(3,4,6)`: |
|
441 | # This can be easily illustrated with an example that has more dimensions; we create an array with 4 dimensions and shape `(3,4,5,6)` and sum along the axis number 2 (i.e. the *third* axis, since in Python all counts are 0-based). That consumes the dimension whose length was 5, leaving us with a new array that has shape `(3,4,6)`: | |
442 |
|
442 | |||
@@ -749,7 +749,7 b" plt.xlabel('x')" | |||||
749 | plt.ylabel('y'); |
|
749 | plt.ylabel('y'); | |
750 |
|
750 | |||
751 | # Out[60]: |
|
751 | # Out[60]: | |
752 |
# image file: tests/ipynbref/IntroNumPy |
|
752 | # image file: tests/ipynbref/IntroNumPy_orig_files/IntroNumPy_orig_fig_01.svg | |
753 |
|
753 | |||
754 | # You can control the style, color and other properties of the markers, for example: |
|
754 | # You can control the style, color and other properties of the markers, for example: | |
755 |
|
755 | |||
@@ -757,13 +757,13 b" plt.ylabel('y');" | |||||
757 | plt.plot(x, y, linewidth=2); |
|
757 | plt.plot(x, y, linewidth=2); | |
758 |
|
758 | |||
759 | # Out[61]: |
|
759 | # Out[61]: | |
760 |
# image file: tests/ipynbref/IntroNumPy |
|
760 | # image file: tests/ipynbref/IntroNumPy_orig_files/IntroNumPy_orig_fig_02.svg | |
761 |
|
761 | |||
762 | # In[62]: |
|
762 | # In[62]: | |
763 | plt.plot(x, y, 'o', markersize=5, color='r'); |
|
763 | plt.plot(x, y, 'o', markersize=5, color='r'); | |
764 |
|
764 | |||
765 | # Out[62]: |
|
765 | # Out[62]: | |
766 |
# image file: tests/ipynbref/IntroNumPy |
|
766 | # image file: tests/ipynbref/IntroNumPy_orig_files/IntroNumPy_orig_fig_03.svg | |
767 |
|
767 | |||
768 | # We will now see how to create a few other common plot types, such as a simple error plot: |
|
768 | # We will now see how to create a few other common plot types, such as a simple error plot: | |
769 |
|
769 | |||
@@ -782,7 +782,7 b' plt.errorbar(x, y, xerr=0.2, yerr=0.4)' | |||||
782 | plt.title("Simplest errorbars, 0.2 in x, 0.4 in y"); |
|
782 | plt.title("Simplest errorbars, 0.2 in x, 0.4 in y"); | |
783 |
|
783 | |||
784 | # Out[63]: |
|
784 | # Out[63]: | |
785 |
# image file: tests/ipynbref/IntroNumPy |
|
785 | # image file: tests/ipynbref/IntroNumPy_orig_files/IntroNumPy_orig_fig_04.svg | |
786 |
|
786 | |||
787 | # A simple log plot |
|
787 | # A simple log plot | |
788 |
|
788 | |||
@@ -792,7 +792,7 b' y = np.exp(-x**2)' | |||||
792 | plt.semilogy(x, y); |
|
792 | plt.semilogy(x, y); | |
793 |
|
793 | |||
794 | # Out[64]: |
|
794 | # Out[64]: | |
795 |
# image file: tests/ipynbref/IntroNumPy |
|
795 | # image file: tests/ipynbref/IntroNumPy_orig_files/IntroNumPy_orig_fig_05.svg | |
796 |
|
796 | |||
797 | # A histogram annotated with text inside the plot, using the `text` function: |
|
797 | # A histogram annotated with text inside the plot, using the `text` function: | |
798 |
|
798 | |||
@@ -812,7 +812,7 b' plt.axis([40, 160, 0, 0.03])' | |||||
812 | plt.grid(True) |
|
812 | plt.grid(True) | |
813 |
|
813 | |||
814 | # Out[65]: |
|
814 | # Out[65]: | |
815 |
# image file: tests/ipynbref/IntroNumPy |
|
815 | # image file: tests/ipynbref/IntroNumPy_orig_files/IntroNumPy_orig_fig_06.svg | |
816 |
|
816 | |||
817 | ### Image display |
|
817 | ### Image display | |
818 |
|
818 | |||
@@ -823,7 +823,7 b' from matplotlib import cm' | |||||
823 | plt.imshow(np.random.rand(5, 10), cmap=cm.gray, interpolation='nearest'); |
|
823 | plt.imshow(np.random.rand(5, 10), cmap=cm.gray, interpolation='nearest'); | |
824 |
|
824 | |||
825 | # Out[66]: |
|
825 | # Out[66]: | |
826 |
# image file: tests/ipynbref/IntroNumPy |
|
826 | # image file: tests/ipynbref/IntroNumPy_orig_files/IntroNumPy_orig_fig_07.svg | |
827 |
|
827 | |||
828 | # A real photograph is a multichannel image, `imshow` interprets it correctly: |
|
828 | # A real photograph is a multichannel image, `imshow` interprets it correctly: | |
829 |
|
829 | |||
@@ -835,7 +835,7 b' plt.imshow(img);' | |||||
835 | # Out[67]: |
|
835 | # Out[67]: | |
836 | # Dimensions of the array img: (375, 500, 3) |
|
836 | # Dimensions of the array img: (375, 500, 3) | |
837 | # |
|
837 | # | |
838 |
# image file: tests/ipynbref/IntroNumPy |
|
838 | # image file: tests/ipynbref/IntroNumPy_orig_files/IntroNumPy_orig_fig_08.svg | |
839 |
|
839 | |||
840 | ### Simple 3d plotting with matplotlib |
|
840 | ### Simple 3d plotting with matplotlib | |
841 |
|
841 | |||
@@ -867,7 +867,7 b' surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet,' | |||||
867 | ax.set_zlim3d(-1.01, 1.01); |
|
867 | ax.set_zlim3d(-1.01, 1.01); | |
868 |
|
868 | |||
869 | # Out[72]: |
|
869 | # Out[72]: | |
870 |
# image file: tests/ipynbref/IntroNumPy |
|
870 | # image file: tests/ipynbref/IntroNumPy_orig_files/IntroNumPy_orig_fig_09.svg | |
871 |
|
871 | |||
872 | ## IPython: a powerful interactive environment |
|
872 | ## IPython: a powerful interactive environment | |
873 |
|
873 |
General Comments 0
You need to be logged in to leave comments.
Login now