Fix Python – How to plot two columns of a pandas data frame using points

I have a pandas dataframe and would like to plot values from one column versus the values from another column. Fortunately, there is plot method associated with the data-frames that seems to do what I need:
df.plot(x=’col_name_1′, y=’col_name_2′)

Unfortunately, it looks like among the plot styles (listed here after the kind parameter) there are n….

Fix Python – Matplotlib Legends not working

Ever since upgrading matplotlib I get the following error whenever trying to create a legend:
/usr/lib/pymodules/python2.7/matplotlib/ UserWarning: Legend does not support []
Use proxy artist instead.


Fix Python – Plot a bar using matplotlib using a dictionary

Is there any way to plot a bar plot using matplotlib using data directly from a dict?
My dict looks like this:
D = {u’Label1′:26, u’Label2′: 17, u’Label3′:30}

I was expecting
fig = plt.figure(figsize=(5.5,3),dpi=300)
ax = fig.add_subplot(111)
bar =,range(1,len(D)+1,1),0.5)

to work, but it does not.
Here is the error:

Fix Python – Moving x-axis to the top of a plot in matplotlib

Based on this question about heatmaps in matplotlib, I wanted to move the x-axis titles to the top of the plot.
import matplotlib.pyplot as plt
import numpy as np
column_labels = list(‘ABCD’)
row_labels = list(‘WXYZ’)
data = np.random.rand(4,4)
fig, ax = plt.subplots()
heatmap = ax.pcolor(data,

# put the major ticks at the midd….

Fix Python – how to draw directed graphs using networkx in python?

I have some nodes coming from a script that I want to map on to a graph. In the below, I want to use Arrow to go from A to D and probably have the edge colored too in (red or something).
This is basically, like a path from A to D when all other nodes are present. you can imagine each nodes as cities and traveling from A to D requires directions (w….

Fix Python – How to export plots from matplotlib with transparent background?

I am using matplotlib to make some graphs and unfortunately I cannot export them without the white background.

In other words, when I export a plot like this and position it on top of another image, the white background hides what is behind it rather than allowing it to show through. How can I export plots with a transparent background instead?

Fix Python – matplotlib get ylim values

I’m using matplotlib to plot data (using plot and errorbar functions) from Python. I have to plot a set of totally separate and independent plots, and then adjust their ylim values so they can be easily visually compared.
How can I retrieve the ylim values from each plot, so that I can take the min and max of the lower and upper ylim values, resp….

Fix Python – Plotting a list of (x, y) coordinates in matplotlib

I have a list of pairs (a, b) that I would like to plot with matplotlib in python as actual x-y coordinates. Currently, it is making two plots, where the index of the list gives the x-coordinate, and the first plot’s y values are the as in the pairs and the second plot’s y values are the bs in the pairs.
To clarify, my data looks like this: li = [….