Prompt Title: Matplotlib Cheatsheet Guide

Created 1 year ago
Votes 0
Views 504 times
IT
0
Human: give me matplotlib cheatsheet
ChatGPT:

Here's a cheatsheet for Matplotlib:

Basics

python
import matplotlib.pyplot as plt plt.plot(x, y) # plot x and y plt.xlabel('x label') # set x-axis label plt.ylabel('y label') # set y-axis label plt.title('title') # set plot title plt.legend() # add legend plt.show() # display plot

Line Plot

python
plt.plot(x, y, color='blue', linewidth=2, linestyle='--', marker='o', markerfacecolor='red', markersize=8) # plot customization

Scatter Plot

python
plt.scatter(x, y, s=50, c='green', alpha=0.5, edgecolors='none')

Bar Plot

python
plt.bar(x, y, align='center', alpha=0.5)

Histogram

python
plt.hist(x, bins=10, color='blue', edgecolor='black')

Subplots

python
plt.subplots(nrows=2, ncols=2) # create 2x2 grid of subplots ax1 = plt.subplot(2, 2, 1) # select first subplot ax1.plot(x1, y1) # plot in first subplot

Annotations

python
plt.text(x, y, 'text', fontsize=12) # add text annotation plt.annotate('annotate', xy=(x,y), xytext=(a,b), arrowprops=dict(facecolor='black', shrink=0.05)) # add arrow annotation

These are some of the most commonly used functions in Matplotlib. For more information, please refer to the official Matplotlib documentation.

avatar
wolfini
Shared 2 prompts
Created 1 year ago

Leave a Comment

Related Tag Prompts

57
1
281
16
0
0
Data
1 year ago 2023-03-08 13:15:35 Data1
0
0
what is about pooling ?
1 year ago 2023-03-09 05:44:33 Sidiki
0
0
Excel: Rank User Reviews.
1 year ago 2023-03-09 13:17:18 Kazakov
0
0
DataBase
1 year ago 2023-03-14 09:59:58 Danh Tuan
0
0
AI Power in Future
1 year ago 2023-03-14 17:48:17 Borja Lorenz
0
0
正态分布
1 year ago 2023-03-18 02:54:38 zhangyu
0
0
biography
1 year ago 2023-03-21 20:13:59 Marina Palupanova
0
0
UNODC’s new data portal
1 year ago 2023-03-27 01:57:29 UNODC
0
0
0
0
0
0
算法翻译请求
1 year ago 2023-04-13 02:34:35 HC
0
1
GIPaaS 魔力象限
1 year ago 2023-05-02 03:54:02 Caesa
0
1
Login inquiry response.
1 year ago 2023-05-04 04:47:54 hansol