matplotlib

Easier way to print in bold a string variable in matplotlib

牧云@^-^@ 提交于 2021-02-11 13:40:58
问题 Today I'm having a very specific issue: I want to print a string variable inside a function using plt.text() in bold. I feel I'm pushing Python's graphing capabilities to the limit when mixing mathtext with the usual syntax. So, the important part of the function looks like this: def graph_text(var): string0=f'String is:'+r"$\bf{"+var+"}$" plt.text(string0) The thing is var are some strings that can have between one and three words. By default in mathtext strings are concatenated, so, for var

Simulation with RK4, update ODE variable as the simulation goes

守給你的承諾、 提交于 2021-02-11 13:40:56
问题 Problem : I’m currently making a python app that simulates a set of coupled ordinary differentials equations that depends on a variable, let’s call it « X ». As for now, I’m basically simulating this set of ODE with RK4 for given time then I’m plotting the graph on an animated plot with « matplotlib animation » embedded in tkinter. The fact is that I would like to be able to modify « X » as the equations are resolved so that the simulation can change as we modify this variable. Context : The

How to create a delay between mutiple animations on the same graph (matplotlib, python)

守給你的承諾、 提交于 2021-02-11 13:38:08
问题 This is a reference from a previous question two lines matplotib animation import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation x = np.arange(130, 190, 1) y = 97.928 * np.exp(- np.exp(- 0.1416 *( x - 146.1 ))) z = 96.9684 * np.exp(- np.exp(-0.1530*( x - 144.4))) fig, ax = plt.subplots() line1, = ax.plot(x, y, color = "r") line2, = ax.plot(x, z, color = "g") def update(num, x, y, z, line1, line2): line1.set_data(x[:num], y[:num]) line2.set_data(x[:num], z

How to create a delay between mutiple animations on the same graph (matplotlib, python)

戏子无情 提交于 2021-02-11 13:33:17
问题 This is a reference from a previous question two lines matplotib animation import numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation x = np.arange(130, 190, 1) y = 97.928 * np.exp(- np.exp(- 0.1416 *( x - 146.1 ))) z = 96.9684 * np.exp(- np.exp(-0.1530*( x - 144.4))) fig, ax = plt.subplots() line1, = ax.plot(x, y, color = "r") line2, = ax.plot(x, z, color = "g") def update(num, x, y, z, line1, line2): line1.set_data(x[:num], y[:num]) line2.set_data(x[:num], z

How can I enable `cairo` backend while plotting `igraph` objects on matplotlib?

删除回忆录丶 提交于 2021-02-11 13:31:23
问题 I'm using Jupyter Notebook and trying to make graphs of igraph appear on matplotlib plots. I've found that one of possible solutions is to create GraphArtist class class that draws igraph graphs but, unfortunately, only Cairo-based backends are supported. When I try to use it, no plot is displayed import matplotlib matplotlib.use("cairo") fig = plt.figure() ax = plt.gca() plt.plot(range(10), [i**1.5 for i in range(10)]) #a simplified version of my diagram plt.show() and I get this warning:

How can I enable `cairo` backend while plotting `igraph` objects on matplotlib?

馋奶兔 提交于 2021-02-11 13:29:56
问题 I'm using Jupyter Notebook and trying to make graphs of igraph appear on matplotlib plots. I've found that one of possible solutions is to create GraphArtist class class that draws igraph graphs but, unfortunately, only Cairo-based backends are supported. When I try to use it, no plot is displayed import matplotlib matplotlib.use("cairo") fig = plt.figure() ax = plt.gca() plt.plot(range(10), [i**1.5 for i in range(10)]) #a simplified version of my diagram plt.show() and I get this warning:

I'm reading images on the disk, how to plot like the first 50 images?

给你一囗甜甜゛ 提交于 2021-02-11 13:13:03
问题 I am reading images on the disk, how to make a for and where to put it to plot the first 50 images on the screen, I want to make sure, that I'm reading the right images, it's for deep learning. def load_clef_database(): img_data_list = [] dataset_dir = "/Users/PlantCLEF2015" root = os.path.join(dataset_dir, 'train') filenames = [] # files class_species = [] class_species_unique = [] class_species_unique_id = [] class_familys = [] class_geni = [] class_ids = [] class_contents = [] metadata = [

Histogram `bins` must increase monotonically matplotlib

自作多情 提交于 2021-02-11 13:12:58
问题 this is my code: import numpy as np import matplotlib.pyplot as plt data = np.genfromtxt("C:\\Users\\pearl\\Downloads\\Age group.csv", delimiter=',', names=True, dtype=('U7','U40','U13',int)) x= ['15-19','20-24', '25-29','30-34','35-39','40-44'] y = data[data['birth_type'] == 'Single Birth']['total_number_of_mother'] plt.hist(x,y) plt.show() However, I am getting a value error saying bins must increase monotonically. May I get some help? 来源: https://stackoverflow.com/questions/65263726

Histogram `bins` must increase monotonically matplotlib

夙愿已清 提交于 2021-02-11 13:12:20
问题 this is my code: import numpy as np import matplotlib.pyplot as plt data = np.genfromtxt("C:\\Users\\pearl\\Downloads\\Age group.csv", delimiter=',', names=True, dtype=('U7','U40','U13',int)) x= ['15-19','20-24', '25-29','30-34','35-39','40-44'] y = data[data['birth_type'] == 'Single Birth']['total_number_of_mother'] plt.hist(x,y) plt.show() However, I am getting a value error saying bins must increase monotonically. May I get some help? 来源: https://stackoverflow.com/questions/65263726

How to use NetworkX's rescale_layout?

霸气de小男生 提交于 2021-02-11 13:11:57
问题 I am having a hard time understanding how to use NetworkX's rescale_layout. The documentation says: pos (numpy array) – positions to be scaled. Each row is a position which is not the standard "position dictionary" that the rest of NetworkX uses for plotting. I have tried to use NetworkX's to_numpy_array on the "pos dict" to no success, and the output of to_numpy_array is a Graph adjacency matrix which doesn't mesh with the requirement of rescale_layout 's Each position is one row of the