matplotlib

How to plot a dashed line on seaborn lineplot?

妖精的绣舞 提交于 2021-02-07 11:17:02
问题 I'm simply trying to plot a dashed line using seaborn. This is the code I'm using and the output I'm getting import seaborn as sns import numpy as np import matplotlib.pyplot as plt n = 11 x = np.linspace(0,2,n) y = np.sin(2*np.pi*x) sns.lineplot(x,y, linestyle='--') plt.show() What am I doing wrong? Thanks 回答1: It seems that linestyle= argument doesn't work with lineplot() , and the argument dashes= is a bit more complicated than it might seem. A (relatively) simple way of doing it might be

seaborn scatterplot marker size for ALL markers

时间秒杀一切 提交于 2021-02-07 11:13:29
问题 I can't find out anywhere how to change the marker size on seaborn scatterplots. There is a size option listed in the documentation but it is only for when you want variable size across points. I want the same size for all points but larger than the default! I tried making a new column of integers in my dataframe and set that as the size, but it looks like the actual value doesn't matter, it changes the marker size on a relative basis, so in this case all the markers were still the same size

“Tube” Arrows in Python

老子叫甜甜 提交于 2021-02-07 10:58:27
问题 I am looking for a way to draw a few (O(1)) 3D arrows with python, which are "proper 3D", by which I mean something along the lines of what Mathematica yields, i.e. rod of the arrow looks like a tube. I did not find anything in the matplotlib documentation, but surely there must be a way? 回答1: You may create a solid of revolution from some path defined in 2D to create a 3D arrow. The following code wraps this into a function, which allows to specify some of the arrow parameters. This allows

python plot intersection of line and data

蓝咒 提交于 2021-02-07 10:28:15
问题 I have a data file that looks something like this: 0 0 0.1 0.1 0.2 0.2 0.3 0.3 0.4 0.31 0.5 0.32 0.6 0.35 And I would like to find the the value that intersects with a slope. My code looks like this so far: from numpy import * from pylab import * data = loadtxt('test.dat') strain = data[:,0] stress = data[:,1] E = 1 y = [0, 0.5] x = 0.2, ((y[1] - y[0])/E+0.2) figure(num=None, figsize=(10, 6), dpi=100, facecolor='w', edgecolor='k') plot(strain, stress) plot(x, y) show() 回答1: You can use the

Opening a plot in tkinter only (no matplotlib popup)

孤者浪人 提交于 2021-02-07 10:24:42
问题 I am opening a matplotlib pyplot in a tkinter window with the below code. My issue is that the plot is still popping up in the matplotlib window as well, and I don't know how to stop that. I've tried commenting out each of the plt.plot's but that didn't help. import numpy as np import matplotlib.pyplot as plt import matplotlib matplotlib.use('TkAgg') from numpy import arange, sin, pi from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg from matplotlib

Opening a plot in tkinter only (no matplotlib popup)

為{幸葍}努か 提交于 2021-02-07 10:23:32
问题 I am opening a matplotlib pyplot in a tkinter window with the below code. My issue is that the plot is still popping up in the matplotlib window as well, and I don't know how to stop that. I've tried commenting out each of the plt.plot's but that didn't help. import numpy as np import matplotlib.pyplot as plt import matplotlib matplotlib.use('TkAgg') from numpy import arange, sin, pi from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg from matplotlib

Python: how to color the nodes of a network according to their degree?

时光毁灭记忆、已成空白 提交于 2021-02-07 09:46:41
问题 I have a scale-free network made of 10000 nodes, but the texture of edges and the number of nodes make it too intricate to be made sense of. I want to be able to visually locate the most highly connected nodes. How could I color the nodes based on their degree k? Specifically, I would like to color them based on pre-assigned ranges, such as: Green if 1<k<10 ; Light blue if 11<k<20 ; Blue if 21<k<30 ; Purple if 31<k<40 ; ... Here is how I obtain the network: import networkx as nx import

Non-blocking Matplotlib Animation

那年仲夏 提交于 2021-02-07 09:33:34
问题 I'd like to run a FuncAnimation concurrently to my main program, unfortunately, it's blocking the execution of MainProgram whatever I do. I've tried: plt.show(block=False) program continues but plot shows blank Returning the animation and storing in a variable - MainProgram is blocked Both: MainProgram runs but plot window is blank I am aware of this question, however, I assume that given the use of Animation the solutions presented aren't appropriate. Plotting in a non-blocking way with

Timeserie datetick problems when using pandas.DataFrame.plot method

折月煮酒 提交于 2021-02-07 09:31:34
问题 I just discovered something really strange when using plot method of pandas.DataFrame . I am using pandas 0.19.1 . Here is my MWE: import numpy as np import matplotlib.pyplot as plt import matplotlib.dates as mdates import pandas as pd t = pd.date_range('1990-01-01', '1990-01-08', freq='1H') x = pd.DataFrame(np.random.rand(len(t)), index=t) fig, axe = plt.subplots() x.plot(ax=axe) plt.show(axe) xt = axe.get_xticks() When I try to format my xticklabels I get strange beahviours, then I

contourf in 3D Cartopy

。_饼干妹妹 提交于 2021-02-07 08:55:49
问题 I am looking for help in plotting a (variable) number of filled contours onto a 3D plot. The rub is that the points need to be correctly geo-referenced. I have got the 2D case working, using Cartopy, but one can not simply use mpl_toolkits.mplot3d , since one can only pass one projection into the figure() method. This question was useful, but is focused mostly on plotting a shapefile, while I have all the points and the values at each point for use in the contouring. This question also looked