How to change labels in matplotlib ticks? · The Chat Archive
Explore gpt-4.1-mini-2025-04-14 · OpenAI LMArena Human Preference 140KHow to change labels in matplotlib ticks? Save Share Download ▾ ReportFrom a Chatbot Arena battle The same person sent this prompt to two anonymous models at once. Compare it with grok-3-mini-beta ’s answer. How to change labels in matplotlib ticks?
AssistantCopy response
To change the labels on the ticks in a Matplotlib plot, you can use several methods depending on what exactly you want to do. Here are some common approaches:
1. Using plt.xticks() or plt.yticks()
You can set the tick locations and their corresponding labels directly.
Copy first prompt Copy first response
Other models, same or similar prompt Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Details
Model gpt-4.1-mini-2025-04-14
Provider OpenAI
Model provenance As recorded by source dataset
Turns 1 (2 messages)
Language es
Added to archive Nov 16, 2026
ID 01m7jf92tpdexnj3ft57r5b9p5Source & license Imported from LMArena Human Preference 140K (source ). Imported records earn no Research Points.
Upstream record: a58d7af8-5d08-4d01-b8c1-c9d14a2e347e:b
Chiang et al., Chatbot Arena: An Open Platform for Evaluating LLMs by Human Preference (2024). LMArena 140K preference release.
License: Prompts CC-BY-4.0; outputs governed by provider terms
Dataset releases Not yet included in a published release.
import matplotlib.pyplot as plt
x = [0, 1, 2, 3]
y = [10, 20, 25, 30]
plt.plot(x, y)
# Set custom x-tick labels
plt.xticks([0, 1, 2, 3], ['zero', 'one', 'two', 'three'])
# Set custom y-tick labels
plt.yticks([10, 20, 25, 30], ['ten', 'twenty', 'twenty-five', 'thirty'])
plt.show()
2. Using ax.set_xticklabels() and ax.set_yticklabels() If you have an Axes object, you can set the labels like this:
fig, ax = plt.subplots()
ax.plot(x, y)
ax.set_xticks([0, 1, 2, 3])
ax.set_xticklabels(['zero', 'one', 'two', 'three'])
ax.set_yticks([10, 20, 25, 30])
ax.set_yticklabels(['ten', 'twenty', 'twenty-five', 'thirty'])
plt.show()
3. Using FuncFormatter for dynamic formatting If you want to format tick labels dynamically, use FuncFormatter:
import matplotlib.ticker as ticker
def format_func(value, tick_number):
return f'Label {int(value)}'
fig, ax = plt.subplots()
ax.plot(x, y)
ax.xaxis.set_major_formatter(ticker.FuncFormatter(format_func))
plt.show()
Summary
Use plt.xticks(locations, labels) or plt.yticks(locations, labels) for quick label changes.
Use ax.set_xticklabels(labels) and ax.set_yticklabels(labels) when working with axes objects.
Use FuncFormatter for programmatic or conditional label formatting.
If you want, I can provide examples for specific cases!