[PYTHON] How to add new data (lines and plots) using matplotlib

How to add new data (straight lines and plots) using matplotlib

Suppose you have a 2D plot for x1 and y1 as shown below.

import numpy as np
import matplotlib.pyplot as plt

x1 = np.array([1,2,3]) 
y1 = np.array([1,2,3])
plot = plt.scatter(x1,y1,s=50,c="b")

pic2.png

Consider how to add new data to such a single piece of data. Here, (1) straight line (y = x) and (2) plot (x2, y2) are added.

x1 = np.array([1,2,3]) 
y1 = np.array([1,2,3])

#Straight line y=Definition of x
x = np.arange(0,10)
y = x 

#Plot x2,Definition of y2
x2 = np.array([5,6,7])
y2 = np.array([5,6,7])

fig = plt.figure()
ax = fig.add_subplot(1,1,1)

plt.xlabel("x",fontsize=18)
plt.ylabel("y",fontsize=18)

ax.scatter(x1,y1,s=50,c="b")
ax.plot(x,y,c="k")
ax.scatter(x2,y2,s=50,c="r")

pic.png

Recommended Posts

How to add new data (lines and plots) using matplotlib
Upload images to S3 with GUI using tkinter
How to write a GUI using the maya command
Try to make it using GUI and PyQt in Python
How to add new data (lines and plots) using matplotlib
How to draw a graph using Matplotlib
How to divide and process a data frame using the groupby function
Add diagonal lines (hatch) to heatmap (python, matplotlib)
[Python] How to read data from CIFAR-10 and CIFAR-100
How to get article data using Qiita API
How to search HTML data using Beautiful Soup
Data cleaning How to handle missing and outliers
How to use Matplotlib
[Python] [Django] How to use ChoiceField and how to add options
How to apply markers only to specific data in matplotlib
How to scrape horse racing data using pandas read_html
[Morphological analysis] How to add a new dictionary to Mecab
How to add color bars in matplotlib bar plot
How to confirm the Persival theorem using the Fourier transform (FFT) of matplotlib and scipy
Data visualization method using matplotlib (1)
Data visualization method using matplotlib (2)
Graph time series data in Python using pandas and matplotlib
How to handle data frames
[Introduction to Data Scientists] Basics of scientific calculation, data processing, and how to use graph drawing library ♬ Basics of Matplotlib
How to build a LAMP environment using Vagrant and VirtulBox Note
How to get followers and followers from python using the Mastodon API
[Python] How to add rows and columns to a table (pandas DataFrame)
How to format a table using Pandas apply, pivot and swaplevel
How to update a Tableau packaged workbook data source using Python
How to install python using anaconda
[Python] How to FFT mp3 data
Data visualization method using matplotlib (+ pandas) (5)
How to install and use Tesseract-OCR
How to deal with imbalanced data
How to add sudo when debugging
How to run matplotlib on heroku
How to install and configure blackbird
How to use .bash_profile and .bashrc
How to install CUDA and nvidia-driver
How to install and use Graphviz
Data visualization method using matplotlib (+ pandas) (3)
How to Data Augmentation with PyTorch
How to add AWS EBS volume
Data visualization method using matplotlib (+ pandas) (4)
How to collect machine learning data
How to solve slide puzzles and 15 puzzles
How to generate a new loggroup in CloudWatch using python within Lambda
[Python] How to specify the window display position and size of matplotlib
[Django 2.2] Add a New badge to new posts with a date using a template filter
[Circuit x Python] How to expand and calculate transfer functions using Lcapy
(Mac) How to display Japanese with Matplotlib and Seaborn At MacOS Sierra
How to plot galaxy visible light data using OpenNGC database in python
[python] How to add RDF triples to your own Fuseki server using rdflib
How to search using python's astroquery and get fits images with skyview
[Linux] How to subdivide files and folders
How to package and distribute Python scripts
How to title multiple figures with matplotlib
How to suppress display error in matplotlib
From Python to using MeCab (and CaboCha)
How to set up SVM using Optuna
How to install a package using a repository
Dump SQLite3 data and migrate to MySQL
python: How to use locals () and globals ()
Separation of design and data in matplotlib