Saltar al contenido principal
LibreTexts Español

42.1: Matplotlib

  • Page ID
    115493
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Estaremos usando bastante la biblioteca matplotlib para visualizar los conceptos en este curso. Esta es una biblioteca muy grande con muchos componentes. Aquí hay algunos conceptos básicos para comenzar.

    Primero, para poder ver las cifras generadas por la biblioteca matplotlib en un cuaderno de jupyter necesitarás agregar lo siguiente como a una celda de código en algún lugar cerca de la parte superior del cuaderno. Este tipo de código debe ejecutarse antes de que se muestren las cifras.

    %matplotlib inline

    A continuación, normalmente importamos los paquetes pylab o pyplot de la biblioteca matplotlib usando una de las siguientes instrucciones de importación. En la mayoría de los casos estas declaraciones son intercambiables, sin embargo, en esta clase generalmente nos apegaremos a usar pyplot porque tiene un poco más de funcionalidad.

    import matplotlib.pylab as plt

    o

    import matplotlib.pyplot as plt

    La forma básica de trazar valores es usar la función plot de la siguiente manera:

    y = [0,1,4,9,16,25,36]
    plt.plot(y);

    La biblioteca matplotlib es grande!!! No hay manera de que podamos cubrir todos los temas en este cuaderno. Sin embargo, no es tan difícil de usar y hay un montón de tutoriales y ejemplos en Internet.

    Hacer esto

    Revise los ejemplos de matplotlib en la Galería de ejemplos de Matplotlib.


    This page titled 42.1: Matplotlib is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Dirk Colbry via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.