matplotlib

plot errorbar with matplotlib based on multiindex pandas dataframe

左心房为你撑大大i 提交于 2021-01-28 05:17:47
问题 I have the following dataframe in pandas: >>>name Hour trt_level stress date value 0 D43 9 H control 2019-06-07 0.4561 1 D43 10 H control 2019-06-07 0.3216 2 D42 8 M stress 2019-06-07 0.2143 3 D42 9 M stress 2019-06-07 0.1342 4 D21 8 L stress 2019-06-07 0.3214 ... I want to create line chart with error-bar,with mse/std, something that will look like this: from : https://matplotlib.org/1.2.1/examples/pylab_examples/errorbar_demo.htmlbut in my case: the X-axis should be hour, the y axis the

How to change the marker symbol of errorbar limits in matplotlib?

≡放荡痞女 提交于 2021-01-28 05:13:59
问题 just a quick question, where I couldn't find anything helpful in the plt.errorbar documentation I want to plot values with error bars: import matplotlib.pyplot as plt plt.errorbar(1, 0.25, yerr=0.1, uplims=True, lolims=True, fmt='o') plt.show() But I would like to have error bars with a simple horizontal line instead of arrows at the ends. But there is no "capmarker" or similar option in the plt.errorbar() function 回答1: Remove the uplims=True and lolims=True ; both limits are plotted by

Plot sequential box plots in matplotlib (control and treatment groups)

泄露秘密 提交于 2021-01-28 05:12:58
问题 I have measurements from control and treatment groups at sequential times, and I would like to plot the box plots of the measurements at each time with the times in order along the x-axis. How do I do this? It looks like there are examples out there of multiple box plots next to each other, but having them organized according to some time variable is eluding me. I'll give some example data in a "tidy" data frame. X is the measurement, T is the time, and G is the group. X | T | G ========== 1

plt.imread(img) raises PIL.UnidentifiedImageError

我的未来我决定 提交于 2021-01-28 05:12:20
问题 So when I try to use imread on a TIFF-file, it raises this error. The TIFF-file in question is a TIFF I created and modified in another script. I initially created it like this: temp = np.full([max_y, max_x], np.nan) . Then I looped the cells and changed the cell values. Afterwards I used cv2.imwrite to write it to a file. However the original script where I create and modify the TIFF-file also opens it after writing the file so no clue why it opens then, and not in this new script. The only

Why are the arguments to Matplotlib's plot_wireframe two dimensional arrays?

冷暖自知 提交于 2021-01-28 05:08:16
问题 I cannot find a clear explanation of the X, Y, and Z arguments to Matplotlib's plot_wireframe function. I have been playing with their provided example wire3d_demo.py but I don't get why X, Y, and Z are two dimensional arrays. It is a pretty curved 3D picture but if you look at the X, Y, and Z arrays they are all size 120 by 120 2D arrays. Matplotlib's documentation has this terse description: "Data values". Can anyone elaborate on that a little bit? I like Matplotlib but its documentation

Python: Matplotlib: how to print ONE text with different sizes in it?

ぐ巨炮叔叔 提交于 2021-01-28 05:06:05
问题 is it possible in matplotlib to have a textbox with different font sizes within one string? Thanks for help 回答1: I don't think this can be done without using the LaTeX text renderer. To use this do, from matplotlib import rcParams rcParams['text.usetex'] = True Then you can print multi-fontsize strings using standard LaTeX syntax, e.g. from matplotlib import pyplot as plt ax = plt.axes() ax.text(0.5, 0.5, r'{\tiny tiny text} normal text {\Huge HUGE TEXT}') Sometimes the LaTeX font renderer

Python: Matplotlib: how to print ONE text with different sizes in it?

早过忘川 提交于 2021-01-28 05:04:34
问题 is it possible in matplotlib to have a textbox with different font sizes within one string? Thanks for help 回答1: I don't think this can be done without using the LaTeX text renderer. To use this do, from matplotlib import rcParams rcParams['text.usetex'] = True Then you can print multi-fontsize strings using standard LaTeX syntax, e.g. from matplotlib import pyplot as plt ax = plt.axes() ax.text(0.5, 0.5, r'{\tiny tiny text} normal text {\Huge HUGE TEXT}') Sometimes the LaTeX font renderer

Saving interactive series on matplotlib figures (html)

依然范特西╮ 提交于 2021-01-28 04:54:29
问题 I have an example (from matplotlib) for an interactive plot where I can select from the series which lines I want to display on the plot. This works perfectly but now I want to export this to an html. I can successfully do this with mpld3.save_html() but lose the interactivity on the series selection. Here's the code import numpy as np import matplotlib.pyplot as plt, mpld3 from matplotlib.widgets import CheckButtons t = np.arange(0.0, 2.0, 0.01) s0 = np.sin(2*np.pi*t) s1 = np.sin(4*np.pi*t)

Small square instead of line in legend?

痞子三分冷 提交于 2021-01-28 04:34:07
问题 To make a custom legend, I currently use the following: handles, labels = plt.gca().get_legend_handles_labels() my_artist = plt.Line2D((0,1),(0,0), color = "blue", linestyle = "-", linewidth = 1) plt.legend([handle for i,handle in enumerate(handles) if i in display]+[my_artist], [label for i,label in enumerate(labels) if i in display]+["My legend"]) It will draw a blue line in the legend box. Instead of a line I would like to have a small blue square (but larger than a simple marker). How to

Negative values bars on the same matplotlib chart

喜欢而已 提交于 2021-01-28 04:33:20
问题 I am trying to display 3 bar charts on the same plot. There is an issue with bars that have negative values though, because they are hanging down either from the top or from nowhere. Any ideas how to make it look nicer? import pandas as pd import matplotlib.pyplot as plt x = range(6) a1 = [-1, -4, -3, -6, 2, 8] a2 = [ 4, 12, 8, 1, 10, 9] a3 = [100, 110, 120, 130, 115, 110] df = pd.DataFrame(index=x, data={'A': a1, 'B': a2, 'C': a3}) fig, ax = plt.subplots() ax2 = ax.twinx() ax3 = ax.twinx()