Skip to main content

All Questions

Tagged with
161 votes
3 answers
246k views

Prevent scientific notation

I have the following code: plt.plot(range(2003,2012,1),range(200300,201200,100)) # several solutions from other questions have not worked, including # plt.ticklabel_format(style='sci', axis='x', ...
Travis Osterman's user avatar
165 votes
5 answers
238k views

Annotate bars with values on Pandas bar plots

I was looking for a way to annotate my bars in a Pandas bar plot with the rounded numerical values from my DataFrame. >>> df=pd.DataFrame({'A':np.random.rand(2),'B':np.random.rand(2)},index=[...
leroygr's user avatar
  • 2,549
771 votes
4 answers
1.2m views

When to use cla(), clf() or close() for clearing a plot

Matplotlib offers these functions: cla() # Clear axis clf() # Clear figure close() # Close a figure window When should I use each function and what exactly does it do?
southoz's user avatar
  • 7,731
99 votes
4 answers
217k views

Create own colormap using matplotlib and plot color scale

I have the following problem, I want to create my own colormap (red-mix-violet-mix-blue) that maps to values between -2 and +2 and want to use it to color points in my plot. The plot should then have ...
Trollbrot's user avatar
  • 1,361
319 votes
21 answers
376k views

Is there a way to detach matplotlib plots so that the computation can continue?

After these instructions in the Python interpreter one gets a window with a plot: from matplotlib.pyplot import * plot([1,2,3]) show() # other code Unfortunately, I don't know how to continue to ...
meteore's user avatar
  • 4,805
245 votes
10 answers
299k views

Plotting in a non-blocking way with Matplotlib

I am having problems trying to make matplotlib plot a function without blocking execution. I have tried using show(block=False) as some people suggest, but all I get is a frozen window. If I simply ...
opetroch's user avatar
  • 4,124
189 votes
8 answers
433k views

Plot smooth line with PyPlot

I've got the following simple script that plots a graph: import matplotlib.pyplot as plt import numpy as np T = np.array([6, 7, 8, 9, 10, 11, 12]) power = np.array([1.53E+03, 5.92E+02, 2.04E+02, 7....
Paul's user avatar
  • 4,470
93 votes
6 answers
84k views

Pandas bar plot changes date format

I have a simple stacked line plot that has exactly the date format I want magically set when using the following code. df_ts = df.resample("W", how='max') df_ts.plot(figsize=(12,8), stacked=True) ...
Ted Petrou's user avatar
  • 62.4k
572 votes
13 answers
944k views

Hiding axis text in matplotlib plots

I'm trying to plot a figure without tickmarks or numbers on either of the axes (I use axes in the traditional sense, not the matplotlib nomenclature!). An issue I have come across is where matplotlib ...
Dave's user avatar
  • 6,624
49 votes
1 answer
65k views

Matplotlib y axis values are not ordered [duplicate]

I am trying to plot using matplotlib. The plot showed a problem that the Y axis is not ordered. Here is the code. # -*- coding: UTF-8 -*- import matplotlib.pyplot as plt import matplotlib.dates as ...
林意專's user avatar
  • 501
61 votes
2 answers
125k views

Break // in x axis of matplotlib [duplicate]

Best way to describe what I want to achieve is using my own image: Now I have a lot of dead space in the spectra plot, especially between 5200 and 6300. My question is quite simple, how would I add in ...
GCien's user avatar
  • 2,359
27 votes
3 answers
116k views

How to plot multiple pandas columns

I have dataframe total_year, which contains three columns (year, action, comedy). How can I plot two columns (action and comedy) on y-axis? My code plots only one: total_year[-15:].plot(x='year', y='...
Bilal Butt's user avatar
  • 1,192
97 votes
7 answers
180k views

set ticks with logarithmic scale

It seems that the set_xticks is not working in log scale: from matplotlib import pyplot as plt fig1, ax1 = plt.subplots() ax1.plot([10, 100, 1000], [1,2,3]) ax1.set_xscale('log') ax1.set_xticks([20, ...
Ruggero Turra's user avatar
100 votes
3 answers
253k views

Label data points on plot

If you want to label your plot points using python matplotlib, I used the following code. from matplotlib import pyplot as plt fig = plt.figure() ax = fig.add_subplot(111) A = anyarray B = ...
ashley's user avatar
  • 1,565
16 votes
1 answer
13k views

understanding matplotlib.subplots python [duplicate]

I have constructed a set of pie charts with some help Insert image into pie chart slice My charts look wonderful, now I need to place all 6 of them in a 2x3 figure with common tick marks on the ...
CJD's user avatar
  • 319

15 30 50 per page
1
2 3 4 5
77