Skip to content

set the yaxis parameters(tickformat='p') #1537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fenghuoqiuqiu opened this issue Apr 27, 2019 · 4 comments
Closed

set the yaxis parameters(tickformat='p') #1537

fenghuoqiuqiu opened this issue Apr 27, 2019 · 4 comments

Comments

@fenghuoqiuqiu
Copy link

fenghuoqiuqiu commented Apr 27, 2019

I want to use percentage format(retain four decimal) ,When I set the yaxis parameters(tickformat='p'), but there are always some display problems.

This is my code:

import plotly.offline as py
from plotly.graph_objs import Scatter, Layout
import plotly.graph_objs as go
py.init_notebook_mode(connected=True)

trace1=go.Scatter(
    name="lenged2",
    x=['2018-01','2018-02','2018-03','2018-04','2018-05','2018-06','2018-07','2018-08','2018-09'],
    y=[0.1,0.3,0.5,0.4,0.7,0.3,0.4,0.2,0.4,0.5], 
)

layout=go.Layout(
    showlegend=True, 
    legend=dict(x=1.05,y=1.1),
    xaxis=dict(showticklabels=True),
    yaxis=dict(
                tickformat='p',
                showgrid=False,

))
data=[trace1]
fig=go.Figure(data=data, layout=layout)
py.iplot(fig)

image

Any help is greatly appreciated.

@jonmmease
Copy link
Contributor

Hi @fenghuoqiuqiu, thanks for the report. I've opened a corresponding issue with the JavaScript library at plotly/plotly.js#3814.

As a workaround, you can manually specify the number of decimal places using the '%' format character. For example:

import plotly.offline as py
from plotly.graph_objs import Scatter, Layout
import plotly.graph_objs as go
py.init_notebook_mode(connected=True)

trace1=go.Scatter(
    name="lenged2",
    x=['2018-01','2018-02','2018-03','2018-04','2018-05','2018-06','2018-07','2018-08','2018-09'],
    y=[0.1,0.3,0.5,0.4,0.7,0.3,0.4,0.2,0.4,0.5], 
)

layout=go.Layout(
    showlegend=True, 
    legend=dict(x=1.05,y=1.1),
    xaxis=dict(showticklabels=True),
    yaxis=dict(
                tickformat='.0%',
                showgrid=False,

))
data=[trace1]
fig=go.Figure(data=data, layout=layout)
py.iplot(fig)

newplot-2

@fenghuoqiuqiu
Copy link
Author

thank you for your help,but it remains an unsettling question,I want to use percentage format(retain four decimal,eg. 20.22%) .
When I manually specify the number of decimal places using the '%' format character,it only retain two decimal.But when I use the 'p' format character,there are always some display problems.

image

@fenghuoqiuqiu
Copy link
Author

thank you for your help,but it remains an unsettling question,I want to use percentage format(retain four decimal,eg. 20.22%) .
When I manually specify the number of decimal places using the '%' format character,it only retain two decimal.But when I use the 'p' format character,there are always some display problems.

@jonmmease

@gvwilson
Copy link
Contributor

Hi - we are currently trying to tidy up Plotly's public repositories to help us focus our efforts on things that will help users most. Since this issue has been sitting for several years, I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our backlog. Thanks for your help - @gvwilson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants