- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 set the font style to Bold in Python Plotly?
Plotly is an open-source Python library for creating charts. You can use its features to customize the fonts in various formats. In this tutorial, we will show how you can set the font style to Bold in Python Plotly.
Here, we will use the plotly.graph_objects module to generate figures. It contains a lot of methods to customize the charts and render them into HTML format.
Then we will use the update_layout() method to set the title as bold format with <b> tag.
Follow the steps given below to set the font style to bold in Plotly.
Step 1
Import the plotly.graphs_objs module and alias as go.
import plotly.graphs_objs as go
Step 2
Create a dataframe using the following coordinates −
data = { 'species':[12,13,11,14,15], 'age':[5,6,7,8,9] } df = pd.DataFrame(data)
Step 3
Create a Bar chart with the following X and Y axis values
fig = go.Figure(go.Bar( x=df['species'], y=df['age']) )
Step 4
Use the update_layout() method to set the title of the bar chart in bold.
fig.update_layout(title='<b>Bar chart</b>')
Step 5
Set the Y-axis label with bold font family as defined below −
fig.update_yaxes(tickfont_family="Arial Black")
Finally, display the chart using fig.show().
Example
The complete code to set the font style to bold is as follows −
import plotly.graph_objects as go import pandas as pd data = { 'species':[12,13,11,14,15], 'age':[5,6,7,8,9] } df = pd.DataFrame(data) fig = go.Figure(go.Bar( x=df['species'], y=df['age']) ) fig.update_layout(title='Bar chart') fig.update_yaxes(tickfont_family="Arial Black") fig.show()
Output
On execution, it will show the following output on the browser −
Notice that the Y-axis labels in the chart are set in bold.
- Related Articles
- How to set the line color in Python Plotly?
- Set the font style with CSS
- How to set the range of Y-axis in Python Plotly?
- How to set font face, style, size and color for JTextPane text in Java
- Python Plotly – How to manually set the color of points in a scatter plot?
- How to set whether the style of the font is normal, italic or oblique with JavaScript?
- Python Plotly – How to hide legend entries in a Plotly figure?
- How to change the font style of IText using FabricJS?
- How to change the font style of Text using FabricJS?
- How to set font color in HTML?
- How to draw a multiple line chart using Plotly Express in Python Plotly?
- How to set font to text node in JavaFX?
- How to change the font style of a Textbox using FabricJS?
- Bold font weight for LaTeX axes label in Matplotlib
- How to set text font family in HTML?
