Hoja de repaso: Python Data Import and Plotting

Course Outline

  1. Python Programming Context
  2. Data File Organization
  3. NumPy Data Import
  4. Matplotlib Plot Construction
  5. Points Vectors and Annotations

1. Python Programming Context

★ Must-know

  • Python is a programming language developed since 1989 whose simple syntax is based on indentation rather than symbols.

  • This course focuses on two Python applications in physics and chemistry: importing data and representing data graphically.

Further detail

  • Python can be used online with the Python laboratory or through distributions such as E-dypthon and Anaconda.

2. Data File Organization

Key Concepts & Definitions

  • Data table : Organized into rows and columns and commonly contains two columns for the data used in the course.

★ Must-know

  • A data file may use a comma or a point to separate the integer and decimal parts of numerical values, so the separator format must be identified before import.

Further detail

  • Before importing a file, the user must identify the number of lines to ignore, including possible column headings or units, and the columns to import.

  • The example data file is named donnees.txt and contains measurements arranged in columns such as t, x, and y, with units shown in a separate line.

3. NumPy Data Import

Key Concepts & Definitions

  • numpy.loadtxt : () is a NumPy function used to retrieve numerical data from a text file and place it into an array.

★ Must-know

  • The delimiter parameter specifies the character separating columns in the data file.

📌 The skiprows parameter specifies the number of lines to skip when importing the file.

  • The usecols parameter selects one or more columns to import from the file.

Further detail

  • The dtype parameter specifies the chosen data type for imported values.

  • The loadtxt parameters comments, converters, unpack, and encoding respectively identify comment-starting characters, convert character strings into numbers, return data in separate columns when set to True, and specify the file encoding.

4. Matplotlib Plot Construction

Key Concepts & Definitions

  • matplotlib.pyplot : A Python library module that provides functions for representing data graphically, including point clouds.

★ Must-know

  • A basic graphing program imports NumPy and matplotlib.pyplot, loads x and y data with numpy.loadtxt(), plots the data, adds labels, and displays the graph.

  • The axis() function sets the graph axes, title() adds a graph title, and xlabel() and ylabel() label the horizontal and vertical axes.

Further detail

  • The legend() function displays the graph legend and show() displays the graphs on screen.

  • In the example, plt.plot(x, y, 'o-', color="red", marker="o", linewidth=1, label="vitesse") creates a red point-and-line plot labelled vitesse.

5. Points Vectors and Annotations

★ Must-know

  • The plot() function places points or connects abscissas and ordinates from the x and y lists, and its color, label, and marker parameters customize the display.

  • The quiver() function draws vectors using the origin coordinates x and y, the vector components, and additional display parameters.

  • The completed matplotlib graph represents the trajectory of a falling ball and includes several velocity vectors.

Further detail

  • The example uses vx=[0.007, 0.013, 0.019], vy=[0.002, 0.002, -0.001], ax=[0.0, 0.02, 0.04], and ay=[1.503, 1.507, 1.505] to draw three velocity vectors.

Pon a prueba tus conocimientos

Pon a prueba tus conocimientos sobre Python Data Import and Plotting con 14 preguntas de opción múltiple con correcciones detalladas.

1. What structural feature does Python use to define blocks of code?

2. Which pair of applications is emphasized for Python in physics and chemistry?

Realiza el cuestionario →

Repasa con tarjetas de memoria

Memoriza los conceptos clave de Python Data Import and Plotting con 36 tarjetas de memoria interactivas.

What is the basis of Python's simple syntax?

Indentation rather than symbols.

Since when has Python been developed?

Since 1989.

How can Python be used online?

With the Python laboratory.

Ver tarjetas de memoria →

Similar courses

Crea tus propias hojas de repaso

Importa tu curso y la IA genera hojas, cuestionarios y tarjetas de memoria en 30 segundos.

Generador de hojas