matplotlib
Giving graphs a subtitle in matplotlib
I want to give my graph a title in big 18pt font, then a subtitle below it in smaller 10pt font. How can I do this in matplotlib? It appears the title() function only takes one single string with a single fontsize attribute. There has to be a way to do this, but how?
Display an image with Python
If you are using matplotlib and want to show the image in your interactive notebook, try the following:
When to use cla(), clf() or close() for clearing a plot in matplotlib?
They all do different things, since matplotlib uses a hierarchical order in which a figure window contains a figure which may consist of many axes. Additionally, there are functions from the pyplot interface and there are methods on the Figure class. I will discuss both cases below. pyplot interface pyplot is a module that collects a couple of … Read more
How to plot time series in python
Convert your x-axis data from text to datetime.datetime, use datetime.strptime: This is an example of how to plot data once you have an array of datetimes:
matplotlib using twinx and twiny together (like twinxy)
If I understand your question right, you want to plot two things on the same axes with no shared axis. There is probably a better way to do this, but you can stack twinx (doc) and twiny (doc) as such Which will give you tick marks on all sides of the plot. ax will plot against the bottom and left, ax_new will plot against the top and right.
How can I convert an RGB image into grayscale in Python?
How about doing it with Pillow: If an alpha (transparency) channel is present in the input image and should be preserved, use mode LA: Using matplotlib and the formula you could do:
pyplot scatter plot marker size
This can be a somewhat confusing way of defining the size but you are basically specifying the area of the marker. This means, to double the width (or height) of the marker you need to increase s by a factor of 4. [because A = WH => (2W)(2H)=4A] There is a reason, however, that the size of markers is … Read more
Python,IndexError: arrays used as indices must be of integer (or boolean) type
Iam getting an IndexError: arrays used as indices must be of integer (or boolean) type at the line for pcolormesh, any idea how to handle this. script: The error:
How to plot ROC curve in Python
I am trying to plot a ROC curve to evaluate the accuracy of a prediction model I developed in Python using logistic regression packages. I have computed the true positive rate as well as the false positive rate; however, I am unable to figure out how to plot these correctly using matplotlib and calculate the AUC value. … Read more