matplotlib

Matplotlib: align origin of right axis with specific left axis value

时间秒杀一切 提交于 2021-02-07 18:19:18
问题 When plotting several y axis in Matplotlib, is there a way to specify how to align the origin (and/or some ytick labels) of the right axis with a specific value of the left axis? Here is my problem: I would like to plot two set of data as well as their difference (basically, I am trying to reproduce this kind of graph). I can reproduce it, but I have to manually adjust the ylim of the right axis so that the origin is aligned with the value I want from the left axis. I putted below an example

Connecting more than two systems in a sankey diagram using matplotlib gives me misalignment

£可爱£侵袭症+ 提交于 2021-02-07 18:14:54
问题 I am trying to make a slightly complex sankey diagram using matplotlib, It is supposed to be dynamical in the sense that I should be able to change the values of the flows and that all connections should stay connected. This means that I cannot manually adjust the path-lengths like suggested in this example. To familiarise myself with the explicit and implicit connections I tried to continue building from this example of two systems connected together with only one explicit connection. With

Connecting more than two systems in a sankey diagram using matplotlib gives me misalignment

妖精的绣舞 提交于 2021-02-07 18:14:26
问题 I am trying to make a slightly complex sankey diagram using matplotlib, It is supposed to be dynamical in the sense that I should be able to change the values of the flows and that all connections should stay connected. This means that I cannot manually adjust the path-lengths like suggested in this example. To familiarise myself with the explicit and implicit connections I tried to continue building from this example of two systems connected together with only one explicit connection. With

Matplotlib: reorder subplots

痴心易碎 提交于 2021-02-07 18:12:46
问题 Say that I have a figure fig which contains two subplots as in the example from the documentation: I can obtain the two axes (the left one being ax1 and the right one ax2 ) by just doing: ax1, ax2 = fig.axes Now, is it possible to rearrange the subplots ? In this example, to swap them? 回答1: Sure, as long as you're not going to use subplots_adjust (and therefore tight_layout ) after you reposition them (you can use it safely before). Basically, just do something like: import matplotlib.pyplot

Matplotlib: reorder subplots

被刻印的时光 ゝ 提交于 2021-02-07 18:10:21
问题 Say that I have a figure fig which contains two subplots as in the example from the documentation: I can obtain the two axes (the left one being ax1 and the right one ax2 ) by just doing: ax1, ax2 = fig.axes Now, is it possible to rearrange the subplots ? In this example, to swap them? 回答1: Sure, as long as you're not going to use subplots_adjust (and therefore tight_layout ) after you reposition them (you can use it safely before). Basically, just do something like: import matplotlib.pyplot

Matplotlib: reorder subplots

穿精又带淫゛_ 提交于 2021-02-07 18:08:40
问题 Say that I have a figure fig which contains two subplots as in the example from the documentation: I can obtain the two axes (the left one being ax1 and the right one ax2 ) by just doing: ax1, ax2 = fig.axes Now, is it possible to rearrange the subplots ? In this example, to swap them? 回答1: Sure, as long as you're not going to use subplots_adjust (and therefore tight_layout ) after you reposition them (you can use it safely before). Basically, just do something like: import matplotlib.pyplot

Draggable lines select one another in Matplotlib

人盡茶涼 提交于 2021-02-07 17:58:39
问题 I'm trying to create a class of draggable lines using matplotlib handling and picking. The aim is to set different thresholds and intervals on a graph. Here is the code: import matplotlib.pyplot as plt import matplotlib.lines as lines import numpy as np class draggable_lines: def __init__(self, ax, kind, XorY): self.ax = ax self.c = ax.get_figure().canvas self.o = kind self.XorY = XorY if kind == "h": x = [-1, 1] y = [XorY, XorY] elif kind == "v": x = [XorY, XorY] y = [-1, 1] else: print(

Draggable lines select one another in Matplotlib

橙三吉。 提交于 2021-02-07 17:58:29
问题 I'm trying to create a class of draggable lines using matplotlib handling and picking. The aim is to set different thresholds and intervals on a graph. Here is the code: import matplotlib.pyplot as plt import matplotlib.lines as lines import numpy as np class draggable_lines: def __init__(self, ax, kind, XorY): self.ax = ax self.c = ax.get_figure().canvas self.o = kind self.XorY = XorY if kind == "h": x = [-1, 1] y = [XorY, XorY] elif kind == "v": x = [XorY, XorY] y = [-1, 1] else: print(

Draggable lines select one another in Matplotlib

半腔热情 提交于 2021-02-07 17:57:33
问题 I'm trying to create a class of draggable lines using matplotlib handling and picking. The aim is to set different thresholds and intervals on a graph. Here is the code: import matplotlib.pyplot as plt import matplotlib.lines as lines import numpy as np class draggable_lines: def __init__(self, ax, kind, XorY): self.ax = ax self.c = ax.get_figure().canvas self.o = kind self.XorY = XorY if kind == "h": x = [-1, 1] y = [XorY, XorY] elif kind == "v": x = [XorY, XorY] y = [-1, 1] else: print(

matplotlib: change stem plot linewidth

扶醉桌前 提交于 2021-02-07 17:23:38
问题 i have image containing 4 subplots: #!/usr/bin/env python3 import matplotlib.pyplot as plt f, axarr = plt.subplots(2, 2) axarr[0,1].stem([1,3,-4],linefmt='b-', markerfmt='bs', basefmt='k-') plt.show() I want to change the linewidth of one plot (stem plot). Is there an easy way to do this? 回答1: Here is my solution: markerline, stemlines, baseline = plt.stem(x, y) plt.setp(stemlines, 'linewidth', 3) 来源: https://stackoverflow.com/questions/32953201/matplotlib-change-stem-plot-linewidth