matplotlib

updating a 3d python plot during a convergence iteration

ぃ、小莉子 提交于 2021-02-11 15:30:09
问题 I try to create a plotting script that plots my data in two 3d structures (with one variable as a color) that I use in a loop in which the data is supposed to converge. I would like to update the figure every iteration, instead of creating a new figure. Any ideas on how I can achieve this? function: import matplotlib.pyplot as plt import numpy as np def colorplot_3D(network, color_variable_1, color_variable_2): net = network X, Y, Z = net['pore.coords'][net.Ps].T X_max, Y_max, Z_max = np.amax

updating a 3d python plot during a convergence iteration

微笑、不失礼 提交于 2021-02-11 15:30:03
问题 I try to create a plotting script that plots my data in two 3d structures (with one variable as a color) that I use in a loop in which the data is supposed to converge. I would like to update the figure every iteration, instead of creating a new figure. Any ideas on how I can achieve this? function: import matplotlib.pyplot as plt import numpy as np def colorplot_3D(network, color_variable_1, color_variable_2): net = network X, Y, Z = net['pore.coords'][net.Ps].T X_max, Y_max, Z_max = np.amax

imshow() not showing image correctly

我是研究僧i 提交于 2021-02-11 15:28:56
问题 The data I am trying to map out is a matrix of shape 5x64 called 'field_matrix' field_matrix = [ [0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 2 2 2 2 2 2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1] [0 0 0 0 0 0 0 1 0 0 1 2 2 2 2 2 2 2 2 2 0 0 2 2 2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 2 2 2 2 2 2 2 2 2 0 2 2 2 2 2 2 2 0 0 0 0] [0 0 0 0 0 0 0 1 0 1 0 2 2 2 2 2 2 2 2 2 0 2 2 2 2 2 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 2 2 2 2 2 2 2 1 1 1 1 1] [0 0 0 0 0

机器学习-贝叶斯数据集

隐身守侯 提交于 2021-02-11 15:24:24
#朴素贝叶斯定力 import numpy as np import pandas as pd import matplotlib from matplotlib import pyplot as plt %matplotlib inline matplotlib.rcParams['font.sans-serif'] = ['SimHei'] data = pd.read_csv('./010-data_multivar.csv',header=None) #拆分数据 dataset_X,dataset_y = data.iloc[:,:-1],data.iloc[:,-1] # print(dataset_X.head()) dataset_X = dataset_X.values dataset_y = dataset_y.values # print(dataset_y) #将标签去重 classes = list(set(dataset_y)) print(classes) #数据集可视化 def visual_2D_dataset(dataset_X,dataset_y): '''将二维数据集dataset_X和对应的类别dataset_y显示在散点图中''' assert dataset_X.shape[1]==2,'only support dataset with

plt.ion() is preventing MultiCursor from working

无人久伴 提交于 2021-02-11 15:17:49
问题 My full code can generate multiple Matplolib plots in multiple windows. This is how I want it as sometimes I want to see them on 2 screens and see a variety of outputs at the same time. Each window has several 'sharey' subplots and I want to share the cursor, using MultiCursor in the Vertical axis. I am using plt.ion() so that the multiple windows are non-blocking, i.e. they all open at the same time rather than one opening when the previse is closed. When I run the code, plt.ion() seems to

plt.ion() is preventing MultiCursor from working

柔情痞子 提交于 2021-02-11 15:16:10
问题 My full code can generate multiple Matplolib plots in multiple windows. This is how I want it as sometimes I want to see them on 2 screens and see a variety of outputs at the same time. Each window has several 'sharey' subplots and I want to share the cursor, using MultiCursor in the Vertical axis. I am using plt.ion() so that the multiple windows are non-blocking, i.e. they all open at the same time rather than one opening when the previse is closed. When I run the code, plt.ion() seems to

how to plot categorical and continuous data in pandas/matplotlib/seaborn

一曲冷凌霜 提交于 2021-02-11 14:56:27
问题 I am trying to figure out how could I plot this data: column 1 ['genres']: These are the value counts for all the genres in the table Drama 2453 Comedy 2319 Action 1590 Horror 915 Adventure 586 Thriller 491 Documentary 432 Animation 403 Crime 380 Fantasy 272 Science Fiction 214 Romance 186 Family 144 Mystery 125 Music 100 TV Movie 78 War 59 History 44 Western 42 Foreign 9 Name: genres, dtype: int64 column 2 ['release_year']: These are the value counts for all the release years for different

How to add legends (labels) and fix tight layout in a subplot with multiple plots

▼魔方 西西 提交于 2021-02-11 14:54:24
问题 I have the following code to generate a (2,2) gridspec subplots. gs=GridSpec(2,2) fig=plt.figure(figsize= (12,6)) ax1=fig.add_subplot(gs[0,0]) ax2=fig.add_subplot(gs[0,1]) ax3=fig.add_subplot(gs[1,:]) ax1.plot(df_wip[['CADUSD=X', 'INRUSD=X', 'PLNUSD=X']], label= ['CAD', 'INR', 'PLN']) ax1.legend() ax2.plot(df_wip[['BRLUSD=X', 'ZARUSD=X']]) ax2.set_xticks([]) ax3.plot(df_wip[['CL=F', 'GC=F', '^TNX']]) gs.tight_layout(fig) See that the legends are not appropriate, and xticks are tight. How to

How to plot a 3D weight function in python with matplotlib

给你一囗甜甜゛ 提交于 2021-02-11 14:47:51
问题 Is there any Python library/function in order to print in 3D the function "weight" weight(x,y,z) = x**(y*z) + y**(x*z) + z**(x*y) with Python and Matplotlib ? Here is already an interesting link How to plot a 3D density map in python with matplotlib but it shows a density instead of a weight for distributed coordinates X Y Z, for example from -5 to +5 with regular steps 0.1 (where solutions for the weight exists in real numbers). I am just playing around with some math functions and wanted to

Dynamically updating plot (Funcanimation) in matplotlib

人盡茶涼 提交于 2021-02-11 14:44:13
问题 I am trying to do a dynamically updating plot in Matplotlib Python 3.x using Tkinter. It starts with displaying a file dialog for the user to select the .csv file. Here's the example of the .csv file: I want to plot each row then the plot is updated & plotting the next row. Here's what I currently have: plt.style.use('fivethirtyeight') xs =[] ys = [] csvFile = filedialog.askopenfile(mode='r', filetypes=(("CSV file", "*.csv"), ("All files", "*.*")), title="Select a CSV file") csvFile2 = pd