Fix Python – reducing number of plot ticks

I have too many ticks on my graph and they are running into each other.
How can I reduce the number of ticks?
For example, I have ticks:
1E-6, 1E-5, 1E-4, … 1E6, 1E7

And I only want:
1E-5, 1E-3, … 1E5, 1E7

I’ve tried playing with the LogLocator, but I haven’t been able to figure this out.

Fix Python – matplotlib error – no module named tkinter

I tried to use the matplotlib package via Pycharm IDE on windows 10.
when I run this code:
from matplotlib import pyplot

I get the following error:
ImportError: No module named ‘tkinter’

I know that in python 2.x it was called Tkinter, but that is not the problem – I just installed a brand new python 3.5.1.
EDIT: in addition, I also tried to imp….

Fix Python – Plotting a 2D heatmap with Matplotlib

Using Matplotlib, I want to plot a 2D heat map. My data is an n-by-n Numpy array, each with a value between 0 and 1. So for the (i, j) element of this array, I want to plot a square at the (i, j) coordinate in my heat map, whose color is proportional to the element’s value in the array.
How can I do this?

Fix Python – How to add hovering annotations to a plot

I am using matplotlib to make scatter plots. Each point on the scatter plot is associated with a named object. I would like to be able to see the name of an object when I hover my cursor over the point on the scatter plot associated with that object. In particular, it would be nice to be able to quickly see the names of the points that are outlier….

Fix Python – Label axes on Seaborn Barplot

I’m trying to use my own labels for a Seaborn barplot with the following code:
import pandas as pd
import seaborn as sns

fake = pd.DataFrame({‘cat’: [‘red’, ‘green’, ‘blue’], ‘val’: [1, 2, 3]})
fig = sns.barplot(x = ‘val’, y = ‘cat’,
data = fake,
color = ‘black’)
fig.set_axis_labels(‘Colors’, ‘Values’)


Fix Python – Specifying and saving a figure with exact size in pixels

Say I have an image of size 3841 x 7195 pixels. I would like to save the contents of the figure to disk, resulting in an image of the exact size I specify in pixels.
No axis, no titles. Just the image. I don’t personally care about DPIs, as I only want to specify the size the image takes in the screen in disk in pixels.
I have read other threads, ….

Fix Python – Date ticks and rotation in matplotlib

I am having an issue trying to get my date ticks rotated in matplotlib. A small sample program is below. If I try to rotate the ticks at the end, the ticks do not get rotated. If I try to rotate the ticks as shown under the comment ‘crashes’, then matplot lib crashes.
This only happens if the x-values are dates. If I replaces the variable dates w….

Fix Python – How to remove frame from matplotlib (pyplot.figure vs matplotlib.figure ) (frameon=False Problematic in matplotlib)

To remove frame in figure, I write

works perfect with pyplot.figure, but with matplotlib.Figure it only removes the gray background, the frame stays . Also, I only want the lines to show, and all the rest of figure be transparent.
with pyplot I can do what I want, I want to do it with matplotlib for some long reason I ‘d rather not….