-
Notifications
You must be signed in to change notification settings - Fork 7
Closed
Labels
plotRelated to plotting functionsRelated to plotting functions
Description
import matplotlib.pyplot as plt
from matplotlib.ticker import FuncFormatter
# Example data
x = [1, 2, 3, 4, 5]
y = [1000, 2000, 3000, 4000, 5000]
# Define a formatter function
def scale_formatter(value, tick_number):
return f'{value / 1000:.1f}'
# Create the plot
fig, ax = plt.subplots()
ax.plot(x, y)
# Apply the formatter to the y-axis
ax.yaxis.set_major_formatter(FuncFormatter(scale_formatter))
# Add labels
ax.set_xlabel("X-axis")
ax.set_ylabel("Y-axis (scaled)")
plt.show()Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
plotRelated to plotting functionsRelated to plotting functions