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

increase axis ticks pyplot

x = [0,5,9,10,16]
y = [0,1,2,3,5]

x_ticks = np.arange(0, 16, 5)
plt.xticks(x_ticks)

y_ticks = np.arange(0, 5, 2)
plt.yticks(y_ticks)

plt.plot(x, y)
Comment

PREVIOUS NEXT
Code Example
Python :: python sorted descending 
Python :: python - remove repeted columns in a df 
Python :: Unable to locate package python3.6-venv 
Python :: python decimal number into 8 bit binary 
Python :: rotate image pyqt5 
Python :: matplotlib plot data 
Python :: calculate highest frequency or mode in pandas dataframe 
Python :: how to replace nan with 0 in pandas 
Python :: read txt in pandas 
Python :: python get base directory 
Python :: format numbers in dataframe pandas 
Python :: matplotlib plot dpi 
Python :: pip install contractions 
Python :: python print a help of a script 
Python :: python get num classes from label encoder 
Python :: detect stop codon 
Python :: for idx, col_name in enumerate(X_train.columns): print("The coefficient for {} is {}".format(file_name, regression_model.coef_[0][idx])) 
Python :: worksheet merge&center cells python 
Python :: matplotlib plot 
Python :: how to put iput python 
Python :: convert string representation of dict to dict python 
Python :: cv_bridge.core.CvBridgeError: [8UC4] is not a color format. but [bgr8] is. The conversion does not make sense 
Python :: build spacy custom ner model stackoverflow 
Python :: how to get words from a string in python 
Python :: replace space with _ in pandas 
Python :: django logout 
Python :: changes not showing on website server odoo 
Python :: datetime python 
Python :: pandas decimal places 
Python :: how to activate virtual environment in python 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =