
python - Multiple datasets on the same scatter plot - Stack Overflow
Although accepted answer works good but with matplotlib version 2.1.0, it is pretty straight forward to have two scatter plots in one plot without using a reference to Axes import matplotlib.pyplot as plt plt.scatter(x,y, c='b', marker='x', label='1') plt.scatter(x, y, c='r', marker='s', label='-1') plt.legend(loc='upper left') plt.show()
python - How to plot a wav file - Stack Overflow
Sep 5, 2013 · import matplotlib.pyplot as plt import numpy as np import wave file = 'test.wav' with wave.open(file,'r') as wav_file: #Extract Raw Audio from Wav File signal = wav_file.readframes(-1) signal = np.fromstring(signal, 'Int16') #Split the data into channels channels = [[] for channel in range(wav_file.getnchannels())] for index, datum in enumerate ...
python - How to plot normal distribution - Stack Overflow
Dec 31, 2021 · import matplotlib.pyplot as plt import numpy as np import scipy.stats as stats import math mu = 0 variance ...
python - How to change the font size on a matplotlib plot - Stack …
If you are a control freak like me, you may want to explicitly set all your font sizes: import matplotlib.pyplot as plt SMALL_SIZE = 8 MEDIUM_SIZE = 10 BIGGER_SIZE = 12 plt.rc('font', size=SMALL_SIZE) # controls default text sizes plt.rc('axes', titlesize=SMALL_SIZE) # fontsize of the axes title plt.rc('axes', labelsize=MEDIUM_SIZE) # fontsize of the x …
matplotlib - Python Scatter Plot with Multiple Y values for each X ...
Dec 15, 2015 · I am trying to use Python to create a scatter plot that contains two X categories "cat1" "cat2" and each category has multiple Y values. I can get this to work if the number of Y values for each X value is the same by using this following code:
How to automatically annotate maximum value in pyplot
import matplotlib.pyplot as plt import numpy as np import pandas as pd from pandas import Series, DataFrame df = pd.read_csv('macrodata.csv') #Read csv file into dataframe years = df['year'] #Get years column infl = df['infl'] #Get inflation rate column fig10 = plt.figure() win = fig10.add_subplot(1,1,1) fig10 = plt.plot(years, infl, lw = 2 ...
python - Plot correlation matrix using pandas - Stack Overflow
Mar 27, 2019 · import matplotlib.pyplot as plt from heatmap import corrplot plt.figure(figsize=(15, 15)) corrplot(df.corr()) NOTE: heatmap library Requires the Python Imaging Library and Python 2.5+. But you can run it on new virtual-env or simple collab notebook
python - Secondary axis with twinx (): how to add to legend
I have a plot with two y-axes, using twinx(). I also give labels to the lines, and want to show them with legend(), but I only succeed to get the labels of one axis in the legend: import numpy as np
python - Plot smooth line with PyPlot - Stack Overflow
I've got the following simple script that plots a graph: import matplotlib.pyplot as plt import numpy as np T = np.array([6, 7, 8, 9, 10, 11, 12]) power = np.array([1 ...
python - Plot mean and standard deviation - Stack Overflow
May 23, 2017 · I have several values of a function at different x points. I want to plot the mean and std in python, like the answer of this SO question. I know this must be easy using matplotlib, but I have no i...