Python Matplotlib tips!

Click “Xiaobai Xue Vision” above and choose to add “Star” or “Pin“ Heavy stuff, delivered as soon as possible This article introduces practical tips for Python Matplotlib! 1. Add title-title There is a title() in the matplotlib.pyplot object that can set the title of the table. import numpy as np import matplotlib.pyplot as plt # […]

Matplotlib_plotting canvas configuration

Table of Contents Canvas configuration plt.figure() figsize: canvas size, width and height dpi: resolution, pixel density facecolor: background color Draw multiple images on one canvas Multi-picture layout Evenly distributed subplot() function: Graphic nesting add_subplot() function ?Edit using axes() function Use the add axes() function Dual axis display Canvas Configuration plt.figure() figsize: canvas size, width and […]

Solve import matplotlib; matplotlib.use(Agg) # pylint: disable=multiple-statements

Table of Contents Solve import matplotlib; matplotlib.use(‘Agg’) # pylint: disable=multiple-statements Background of the problem solution Summarize Solve import matplotlib; matplotlib.use(‘Agg’) # pylint: disable=multiple-statements In the field of data visualization in Python, matplotlib is a very powerful and popular library. However, sometimes in the process of using ??matplotlib??, we may encounter some problems. For example, in […]

Python matplotlib displays data in real time

#!/usr/bin/env python # -*- coding: utf-8 -*- import socket importsys from PyQt5 import QtWidgets, QtCore from PyQt5.QtWidgets import QPushButton from PyQt5.QtGui import QColor from matplotlib.backends.backend_qt5agg import (FigureCanvasQTAgg, NavigationToolbar2QT as NavigationToolbar) from matplotlib.figure import Figure from matplotlib.font_manager import FontProperties import matplotlib.pyplot as plt from matplotlib import rc import time import datetime import re import_thread import random […]

Use matplotlib to draw simple charts (line charts, column charts, bar charts, stacked area charts, histograms, pie charts, scatter plots, box plots, radar charts, error bar charts)

Line chart #Example 1: Draw a line chart plot() – the highest and lowest temperatures in Beijing in the next 15 days #First import the pyplot module and numpy module in the matplotlib library import matplotlib.pyplot as plt import numpy as np #Create a Figure class object fig representing the canvas and add a drawing […]

Use matplotlib to draw boxplots (boxplot)

Doing machine learning often requires visualizing data. This time I introduce boxplot. Because I often use it in data analysis, I created a small function to make it more convenient for me to use in the future. – boxplot has the following advantages: 1. Display the distribution of data graphically, making it clear at a […]

Draw charts using matplotlib

Foreword: Continue from last time Tips: The following is the text of this article, the following cases are for reference 1. Draw histogram Use hist() to draw a histogram Example: Draw a line histogram with 8 rectangular bar fills, the code is as follows : import numpy as np import matplotlib.pyplot as plt scores = […]

Use matplotlib to draw histograms, pie charts, scatter plots, and error bar plots

1. Draw histogram 1.1 Draw histogram Use pyplot’s hist() function to quickly draw a histogram. The syntax format of the hist() function is as follows: hist(x,bins=None,range=None,density=None,weights=None, rcumulative=False,bottom=None,histtype=’bar’,align=’mid’, orientation=’vertical’,rwidth=None,log=False,label=None, stacked=False,normed=None,*,data=None,**kwargs) The meanings of the common parameters of this function are as follows. x: Represents the data of the x-axis, which can be a single array or […]