matplotlib

matplotlib - module 'sip' has no attribute 'setapi'

醉酒当歌 提交于 2021-02-08 12:35:35
问题 I just set up the VS Code with all the Python extensions. Python version is 3.8.3 through Anaconda. The interpreter is venv. When I run this code import matplotlib.pyplot as plt An error shows - Exception has occurred: AttributeError module 'sip' has no attribute 'setapi' File "C:\test.py", line 145, in <module> import matplotlib.pyplot as plt I've tried uninstalling and reinstalling matplotlib, but to no avail. 回答1: This worked for me. python -m pip install matplotlib==3.2 回答2: There seems

Matplotlib plots lose transparency when saving as .pdf

淺唱寂寞╮ 提交于 2021-02-08 12:18:58
问题 I'm seeing exactly the same issue as this one: Matplotlib Plots Lose Transparency When Saving as .ps/.eps except I am trying to output to PDF rather than ps/eps. The answers to the previous question point out that eps does not support transparency and suggest either rasterising or saving as a PDF. I do get correct looking output when I save as png, so it seems as though matplotlib is dealing with the transparency correctly, but the backend is failing. Clearly PDF does support transparency, so

Seaborn Lineplot Module Object Has No Attribute 'Lineplot'

北城余情 提交于 2021-02-08 12:17:58
问题 Using seaborn's documentation code to generate a lineplot returns an AttributeError: 'module' object has no attribute 'lineplot'. I have updated seaborn and reimported the module and tried again, no luck. Did lineplot get retired, or is there something else going on? import seaborn as sns; sns.set() import matplotlib.pyplot as plt fmri = sns.load_dataset("fmri") ax = sns.lineplot(x="timepoint", y="signal", data=fmri) 回答1: If you are using conda, you need to install seaborn with the version

Seaborn Lineplot Module Object Has No Attribute 'Lineplot'

巧了我就是萌 提交于 2021-02-08 12:17:20
问题 Using seaborn's documentation code to generate a lineplot returns an AttributeError: 'module' object has no attribute 'lineplot'. I have updated seaborn and reimported the module and tried again, no luck. Did lineplot get retired, or is there something else going on? import seaborn as sns; sns.set() import matplotlib.pyplot as plt fmri = sns.load_dataset("fmri") ax = sns.lineplot(x="timepoint", y="signal", data=fmri) 回答1: If you are using conda, you need to install seaborn with the version

Matplotlib plots lose transparency when saving as .pdf

二次信任 提交于 2021-02-08 12:17:08
问题 I'm seeing exactly the same issue as this one: Matplotlib Plots Lose Transparency When Saving as .ps/.eps except I am trying to output to PDF rather than ps/eps. The answers to the previous question point out that eps does not support transparency and suggest either rasterising or saving as a PDF. I do get correct looking output when I save as png, so it seems as though matplotlib is dealing with the transparency correctly, but the backend is failing. Clearly PDF does support transparency, so

Plotting bar charts with a colormap legend

可紊 提交于 2021-02-08 11:42:44
问题 Consider the following: import matplotlib.pyplot as plt from matplotlib import cm import numpy as np y = np.array([1, 4, 3, 2, 7, 11]) colors = cm.hsv(y / float(max(y))) plot = plt.scatter(y, y, c = y, cmap = 'hsv') plt.clf() plt.colorbar(plot) plt.bar(range(len(y)), y, color = colors) plt.show() I want to colormap legend to appear on the top right of the graph (much smaller of course). My image at the moment looks rather clunky as the colormap is clashing somewhat with the actual bars.

Plot point on time series line graph

自作多情 提交于 2021-02-08 11:35:03
问题 I have this dataframe and I want to line plot it. As I have plotted it. Graph is Code to generate is fig, ax = plt.subplots(figsize=(15, 5)) date_time = pd.to_datetime(df.Date) df = df.set_index(date_time) plt.xticks(rotation=90) pd.DataFrame(df, columns=df.columns).plot.line( ax=ax, xticks=pd.to_datetime(frame.Date)) I want a marker of innovationScore with value(where innovationScore is not 0) on open, close line. I want to show that that is the change when InnovationScore changes. 回答1: You

Plot point on time series line graph

回眸只為那壹抹淺笑 提交于 2021-02-08 11:33:36
问题 I have this dataframe and I want to line plot it. As I have plotted it. Graph is Code to generate is fig, ax = plt.subplots(figsize=(15, 5)) date_time = pd.to_datetime(df.Date) df = df.set_index(date_time) plt.xticks(rotation=90) pd.DataFrame(df, columns=df.columns).plot.line( ax=ax, xticks=pd.to_datetime(frame.Date)) I want a marker of innovationScore with value(where innovationScore is not 0) on open, close line. I want to show that that is the change when InnovationScore changes. 回答1: You

matplotlib onclick event repeating

岁酱吖の 提交于 2021-02-08 11:29:19
问题 I want to use the onclick method to select a range of data on my matplotlib graph. But the thing is, I can't do that more than once and update the plot. I have some ideas to do this, one of them would be to make a list of plots where I jump to new indices after I appended the new picture ... but mostly I would like to be able to store the information from the click ( event.xdata ) two times to color the area under the graph in that section - but for starters it would already be an achievement

matplotlib onclick event repeating

丶灬走出姿态 提交于 2021-02-08 11:28:25
问题 I want to use the onclick method to select a range of data on my matplotlib graph. But the thing is, I can't do that more than once and update the plot. I have some ideas to do this, one of them would be to make a list of plots where I jump to new indices after I appended the new picture ... but mostly I would like to be able to store the information from the click ( event.xdata ) two times to color the area under the graph in that section - but for starters it would already be an achievement