matplotlib

Seaborn/Matplotlib: how to access line values in FacetGrid?

僤鯓⒐⒋嵵緔 提交于 2021-02-07 14:25:33
问题 I'm trying to shade the area between two lines in a Seaborn FacetGrid. The fill_between method will do this, but I need to access the values of each line in each subplot to pass them in. Here's my code: import pandas as pd import matplotlib.pyplot as plt import seaborn as sns data = [{'Change': 0.0, 'Language': 'Algonquin', 'Type': 'Mother tongue', 'Year': '2011'}, {'Change': 0.0, 'Language': 'Algonquin', 'Type': 'Spoken at home', 'Year': '2011'}, {'Change': -21.32, 'Language': 'Algonquin',

both a top and a bottom axis in pylab (e.g. w/ different units) (or left and right)

我们两清 提交于 2021-02-07 14:23:30
问题 I'm trying to make a plot with pylab/matplotlib, and I have two different sets of units for the x axis. So what I would like the plot to have is two axis with different ticks, one on the top and one on the bottom. (E.g. one with miles and one with km or so.) Something like the graph below (but than I would like multiple X axes, but that doesn't really matter.) Anyone an idea whether this is possible with pylab? 回答1: This might be a little late but see if something like this would help: http:/

both a top and a bottom axis in pylab (e.g. w/ different units) (or left and right)

独自空忆成欢 提交于 2021-02-07 14:22:20
问题 I'm trying to make a plot with pylab/matplotlib, and I have two different sets of units for the x axis. So what I would like the plot to have is two axis with different ticks, one on the top and one on the bottom. (E.g. one with miles and one with km or so.) Something like the graph below (but than I would like multiple X axes, but that doesn't really matter.) Anyone an idea whether this is possible with pylab? 回答1: This might be a little late but see if something like this would help: http:/

How draw box across multiple axes on matplotlib using ax position as reference

送分小仙女□ 提交于 2021-02-07 14:22:04
问题 I would like to draw a box across multiple axes, using one ax coordinates as reference. The simple code I have, that does not generate the box is import matplotlib.pyplot as plt import numpy as np fig, (ax1, ax2) = plt.subplots(2, 1, sharex=False, sharey=False, figsize=(15,9)) x = 2 * np.pi * np.arange(1000) / 1000 y1 = np.sin(x) y2 = np.cos(x) ax1.plot(x,y1) ax2.plot(x,y2) plt.show() This generate the following figure: What I would like to have is the following figure, using x cordinates

Using pandas to plot barplots with error bars

℡╲_俬逩灬. 提交于 2021-02-07 13:11:31
问题 I'm trying to generate bar plots from a DataFrame like this: Pre Post Measure1 0.4 1.9 These values are median values I calculated from elsewhere, and I have also their variance and standard deviation (and standard error, too). I would like to plot the results as a bar plot with the proper error bars, but specifying more than one error value to yerr yields an exception: # Data is a DataFrame instance fig = data.plot(kind="bar", yerr=[0.1, 0.3]) [...] ValueError: In safezip, len(args[0])=1 but

Draw Marker in Image

烈酒焚心 提交于 2021-02-07 12:44:06
问题 I'm drawing a picture using Matplotlib: plt.imshow(bild) plt.show() How do I add a Marker to this (eg. red dot / arrow) using the coordinates of the image? 回答1: You can also use plt.scatter to add a red dot to mark the point. Building on the previous answer's example code: import matplotlib.pyplot as plt import numpy as np img = np.random.randn(100, 100) plt.figure() plt.imshow(img) plt.annotate('25, 50', xy=(25, 50), xycoords='data', xytext=(0.5, 0.5), textcoords='figure fraction',

How to fix paths to solve Homebrew doctor warnings

会有一股神秘感。 提交于 2021-02-07 12:18:31
问题 Another newbie query. I've been struggling to install matplotlib for a Python project so reading around suggested Homebrew was a solid solution for package management and dependencies. However when I run the Homebrew diagnostics I receive the following error: $ brew doctor Warning: "config" scripts exist outside your system or Homebrew directories. `./configure` scripts often look for *-config scripts to determine if software packages are installed, and what additional flags to use when

What is the difference between importing matplotlib and matplotlib.pyplot?

别等时光非礼了梦想. 提交于 2021-02-07 12:18:31
问题 I'm still fairly new to python and am wondering if the x.y statement means y is a submodule of x? And if so, doesn't the command: import matplotlib.pyplot as plt only import this particular submodule and nothing else? I had to do this in order to get access to the hist function. How does that affect the modules normally imported when calling import matplotlib as plt ? Can I get all the modules in matplotlib together under the plt name? I'm aware that this question is related to what is the

What is the difference between importing matplotlib and matplotlib.pyplot?

天大地大妈咪最大 提交于 2021-02-07 12:17:07
问题 I'm still fairly new to python and am wondering if the x.y statement means y is a submodule of x? And if so, doesn't the command: import matplotlib.pyplot as plt only import this particular submodule and nothing else? I had to do this in order to get access to the hist function. How does that affect the modules normally imported when calling import matplotlib as plt ? Can I get all the modules in matplotlib together under the plt name? I'm aware that this question is related to what is the

How to plot a dashed line on seaborn lineplot?

孤人 提交于 2021-02-07 11:17:47
问题 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