- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to show all the X-axis tick values in Python Plotly?
Plotly is an open-source Python library for creating charts. In this tutorial, we will show how you can use the features of Plotly to display specific axis tick values. Let us understand how to show all the X-axis tick values,
Use plotly.graph_objects to generate figures. It contains a lot of methods to customize chart and render a chart into HTML format.
Update_layout() method has X-axis parameter and the value must be assigned as tickmode='linear'.
Follow the steps given below to show all the X-axis tick values.
Step 1
Import plotly.graphs_objs module and alias as go
import plotly.graphs_objs as go
Step 2
Create a scatter plot using go.Figure() method as follows,
# create a scatter plot fig = go.Figure(go.Scatter( x = [1, 2, 3, 4, 5], y = [28.8, 28.5, 37, 29, 25] ))
Step 3
Create the update_layout() method to set the X-axis dict values.
# update layout for xaxis tickmode as linear fig.update_layout( xaxis = dict( tickmode = 'linear', tick0 = 0.5, dtick = 0.75 ) )
Example
The complete code to display all the X-axis tick value is as follows −
import plotly.graph_objects as go # create a scatter plot fig = go.Figure(go.Scatter( x = [1, 2, 3, 4, 5], y = [28.8, 28.5, 37, 29, 25] )) # update layout for xaxis tickmode as linear fig.update_layout( xaxis = dict( tickmode = 'linear', tick0 = 0.5, dtick = 0.75 ) )
Output
It will show the following output on the browser −
- Related Articles
- How to hide the Y-axis tick labels on a chart in Python Plotly?
- How to display X-axis tick marks as minimum and maximum only without their values using plotly in R?
- Overlapping Y-axis tick label and X-axis tick label in Matplotlib
- How to set X-axis values in Matplotlib Python?
- How to highlight all the values from a group on hover in Python Plotly?
- How to force Matplotlib to show the values on X-axis as integers?
- How to set the range of Y-axis in Python Plotly?
- How to show a Plotly animated slider in Python?
- Hide axis values but keep axis tick labels in matplotlib
- How to rotate X-axis tick labels in Pandas bar plot?
- Show tick labels when sharing an axis in Matplotlib
- How to plot on secondary Y-Axis with Python Plotly?
- How to plot multiple lines on the same Y-axis in Python Plotly?
- How to represent all values of X-axis or Y-axis on the graph in R using ggplot2 package?
- How to append a single labeled tick to X-axis using matplotlib?
