Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Set axis ticks matplotlib

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker

x = [0,5,9,10,15]
y = [0,1,2,3,4]
fig, ax = plt.subplots()
ax.plot(x,y)
start, end = ax.get_xlim()
ax.set_xticks(np.arange(start, end, 2))
plt.show()
Comment

Changing the number of ticks on a Matplotlib plot axis

# Get the current axis
ax = plt.gca()

# Only label every 20 th value
ticks_to_use = df.index[::20]

# Set format of labels(note year not excluded as requested)
labels = [i.strftime("%-H:%M") for i in ticks_to_use]

# Now set the ticks and labels
ax.set_xticks(ticks_to_use)
ax.set_xticklabels(labels)
Comment

PREVIOUS NEXT
Code Example
Python :: pywhatkit 
Python :: datetime.datetime.fromtimestamp() 
Python :: how to write to a netcdf file using xarray 
Python :: concatenate directories python 
Python :: malier module python 
Python :: embed discord.py 
Python :: How to search where a character is in an array in python 
Python :: python fill a list 
Python :: int to list python 
Python :: python creating a dict from a string 
Python :: python remove empty list 
Python :: all letters an numbers py array 
Python :: power level in google colab 
Python :: add column array python 
Python :: how to print a matrix in python 
Python :: csrf token fetch django 
Python :: only size-1 arrays can be converted to Python scalars 
Python :: pathlib path python 
Python :: replace value pandas df 
Python :: pickling and unpickling in python 
Python :: generate n different random numbers python 
Python :: pi python 
Python :: anagram program in python 
Python :: pandas df make set index column 
Python :: set http response content type django 
Python :: check tensor type tensorflow 
Python :: correlation analysis of dataframe python 
Python :: python set grid thickness 
Python :: write list to file python 
Python :: how to plotting bar on matplotlib 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =