plot

Adding image generated from another library as inset in matplotlib

微笑、不失礼 提交于 2021-02-11 16:50:04
问题 I've generated a network figure using vedo library and I'm trying to add this as an inset to a figure generated in matplotlib import networkx as nx import matplotlib.pyplot as plt from vedo import * from matplotlib.offsetbox import OffsetImage, AnnotationBbox G = nx.gnm_random_graph(n=10, m=15, seed=1) nxpos = nx.spring_layout(G, dim=3, seed=1) nxpts = [nxpos[pt] for pt in sorted(nxpos)] nx_lines = [(nxpts[i], nxpts[j]) for i, j in G.edges()] pts = Points(nxpts, r=12) edg = Lines(nx_lines).lw

R - Defining a function which recognises arguments not as objects, but as being part of the call

会有一股神秘感。 提交于 2021-02-11 16:46:16
问题 I'm trying to define a function which returns a graphical object in R. The idea is that I can then call this function with different arguments multiple times using an for loop or lapply function, then plotting the list of grobs in gridExtra::grid.arrange . However, I did not get that far yet. I'm having trouble with r recognising the arguments as being part of the call. I've made some code to show you my problem. I have tried quoting and unquoting the arguments, using unqoute() in the

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

Filter data with Javascript callback in Python's Bokeh

会有一股神秘感。 提交于 2021-02-11 15:19:19
问题 apologies in advance for unprecise/unappreciated wording as this is my first question here. Feel free to point out how I can improve it in the future. I have been reading through all of Bokeh's user guide and various forums but belief this question is still insufficiently covered as it appears over and over again without an answer that can be applied generically. My task is to construct a scatterplot in Python's Bokeh that can interactively be filtered based on a categorical variable. My

How to make custom y-axis scale in base R

感情迁移 提交于 2021-02-11 15:14:37
问题 I am trying to figure out how to make a plot in R with a custom y-axis scale. For, example I would like to make a plot with the same y-axis as below. You can the distance between the tick marks is the same even though the actual numerical distance is not. In order to achieve the same axis look, I can do the following: set.seed(1) n <- 10 x <- 1:n y <- rnorm(n) ticks <- c("1/30","1/10","1/3","1","3","10","30") plot(x, y, axes = FALSE, ylim = c(-3,3)) axis(1) axis(2, seq(-3,3,1), ticks) which

Plotly equivalent for pd.DataFrame.hist

主宰稳场 提交于 2021-02-11 14:46:23
问题 I am looking for a way to imitate the hist method of pandas.DataFrame using plotly. Here's an example using the hist method: import seaborn as sns import matplotlib.pyplot as plt # load example data set iris = sns.load_dataset('iris') # plot distributions of all continuous variables iris.drop('species',inplace=True,axis=1) iris.hist() plt.tight_layout() which produces: How would one do this using plotly? 回答1: Plotly has a histogram function built in so all you have to do is write px.histogram

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

Matplotlib Colorbar Ticks Mathtext Format

浪子不回头ぞ 提交于 2021-02-11 14:37:49
问题 The title is self explanatory, could not find how to implement it. For the axis ticks format similar command looks like this: ax.ticklabel_format(useMathText=True) , there is no problem with this one, it works. But for the colorbar's ticks to make them appear in the MathText format I could not find how to implement it. I have tried to pass the useMathText=True as an arg into the cbar.ax.tick_params() and cbar = plt.colorbar() but that did not work. to recreate: import numpy as np import

exponential decay with scipy just gives step function

微笑、不失礼 提交于 2021-02-11 14:26:35
问题 I'm trying to do an exponential fit with a set of data: import matplotlib.pyplot as plt import numpy as np import scipy.optimize as opt def func(x, a, b, c): return a * np.exp(x / -b) + c epr_data = np.loadtxt('T2_text', skiprows=1) time = epr_data[:, 1] intensity = epr_data[:, 2] optimizedParameters, pcov = opt.curve_fit(func, time, intensity) print(optimizedParameters) plt.plot(time, intensity, func(time, *optimizedParameters), label="fit") plt.show() but i just get this step function and