plotly / dash

Data Apps & Dashboards for Python. No JavaScript Required.
https://plotly.com/dash
MIT License
21.31k stars 2.06k forks source link

Axes labels/titles not appearing #539

Closed gkiar closed 5 years ago

gkiar commented 5 years ago

Hi!

First of all: I'm not sure whether or not this is a Dash or Plotly specific issue, but I'm using them together so figured I'd put the comment here - please redirect me if I'm mistaken.

The behaviour I'm currently getting is that titles specified for both axis and plots are not appearing in the resulting plots. Using older versions of plotly and dash these have produced the expected output. I've attached two figures below, showing the previous and current result. I've also attached a pip freeze of all related packages on my machine.

I'm currently specifying the title as is described quite simply in the documentation, within my layout structure using the title field and a simple string value, i.e. layout = {'title':'my title', 'yaxis': {'title':'my y title', ...}, ...}

Please let me know if there's likely a simple oversight on my part here causing this behaviour. Thanks!

Expected (Previous) Unexpected (Current)
screenshot 2019-01-15 12 44 52 screenshot 2019-01-15 12 50 28
plotly==3.1.1, dash==0.24.1, dash-core-components==0.27.1, dash-html-components==0.11.0, dash-renderer==0.13.0, dash-table-experiments==0.6.0 plotly==3.5.0, dash==0.35.2, dash-core-components==0.42.1, dash-html-components==0.13.5, dash-renderer==0.16.2, dash-table-experiments==0.6.0
alexcjohnson commented 5 years ago

Thanks for bringing this up @gkiar! Presumably related to https://github.com/plotly/plotly.js/pull/3276 where we changed from: layout={title: 'my title'} to: layout={title: {text: 'my title'}} The older form is still expected to work, but until we figure out what's going on here you should be able to get the desired result by changing to the new form of title attributes.

gkiar commented 5 years ago

Hi @alexcjohnson - thanks for the quick response!

I actually have been printing my Figure object out to debug, and it is being properly converted, i.e. it shows up as the following: 'title': {'text': 'Usage Stats'}.

Any idea what would cause the property to not be rendered, despite it being in the figure object? I inspected the plot in the console and found the title elements to be blank:

<g class="infolayer">
  <g class="g-gtitle"></g>
  <g class="g-xtitle"></g>
  <g class="g-ytitle"></g>
  <g class="g-y2title"></g>
</g>
alexcjohnson commented 5 years ago

Could it be that you somehow have an old plotly.js version, despite having updated dash? In the console, you can type Plotly.version. Also to see what's actually supplied to the plot, you can select the class="js-plotly-plot" element and type $0.layout.title. Here's what I see in a currently-working example at https://dash.plot.ly/dash-core-components:

screen shot 2019-01-15 at 2 34 11 pm
gkiar commented 5 years ago

@alexcjohnson I think you found the issue - the layout object is correctly set, but my plotly version is 1.39.1. Is there a guide somewhere on how to ensure that the javascript library also get updated when I update the Python component? Thanks!

gkiar commented 5 years ago

Ah, I was using a "custom" dash.Dash class in my code, as I believe at one point this was the recommended way to specify page title and some other information. It now appears I can do this a better way, so I've reverted back to using the default dash.Dash, and all is working as expected :) Thanks!

s3630237 commented 3 years ago

Hi Guys,

Not sure if this related to the issue here, but I'm finding that my plotly express plots work fine in Jupyter notebook, but I get minor issues when I generate the exact plot in Dash. For example, x and y titles do not generate, specific hover info that I set does not appear, continuous color bars do not appear from a scatter_mapbox. Furthermore sunburst and treemaps do not generate at all. All these features work within Jupyter notebook. Does anybody have any idea on where I can start to solve these problems? Many thanks, Bill

alexcjohnson commented 3 years ago

@s3630237 that sounds consistent with an old plotly.js version. dash-core-components has its own copy of plotly.js, and you'll get the latest dcc if you update dash itself.

s3630237 commented 3 years ago

Thanks Alex for getting back to me so quickly. Ive already upgraded dash, by typing the following at the command prompt "easy_install --upgrade Dash". Below is a listing of my dash packages when i type 'pip list'. I'm pretty sure these are the most up to date dash packages. Is there another way I should be doing this r is there another command I should by tping to upgrade plotly.js?

dash 1.19.0 dash-core-components 1.15.0 dash-html-components 1.1.2 dash-renderer 1.9.0 dash-table 4.11.2 dash-update-data-components 0.0.1

alexcjohnson commented 3 years ago

Yes, that's up to date. What do you get if you open the JS console when viewing your dash app and type Plotly.version? It should be "1.58.4"

s3630237 commented 3 years ago

Hi Alex, sorry I'm quite new to this. How would I open the JS console? I can see a terminal tab and python console tab at the bottom pane of pycharm. Ive typed Plotly.version in both and have received an error. Cheers, Bill

From: Alex Johnson notifications@github.com Sent: Thursday, 4 February 2021 12:32 PM To: plotly/dash dash@noreply.github.com Cc: Bill Koutsovasilis s3630237@student.rmit.edu.au; Mention mention@noreply.github.com Subject: Re: [plotly/dash] Axes labels/titles not appearing (#539)

Yes, that's up to date. What do you get if you open the JS console when viewing your dash app and type Plotly.version? It should be "1.58.4"

- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fplotly%2Fdash%2Fissues%2F539%23issuecomment-772956688&data=04%7C01%7Cs3630237%40student.rmit.edu.au%7C2b134dd2cecf42d1a1bd08d8c8acbc3e%7Cd1323671cdbe4417b4d4bdb24b51316b%7C0%7C0%7C637479991515388749%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=pN7UACrxOUE6T7troKxq12NXIiOyFiTxoW0yOFGYdGI%3D&reserved=0, or unsubscribehttps://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAO2ZL3DVDHPAAODZOZ36GQLS5H2KVANCNFSM4GQF72EQ&data=04%7C01%7Cs3630237%40student.rmit.edu.au%7C2b134dd2cecf42d1a1bd08d8c8acbc3e%7Cd1323671cdbe4417b4d4bdb24b51316b%7C0%7C0%7C637479991515388749%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=gsY754WBP4%2BrhlCIlWEX3qn0ZaLEUxs%2F0BNlvmlpQVM%3D&reserved=0.

alexcjohnson commented 3 years ago

In the browser where you're viewing the dash app. If you're using Chrome this is "developer tools" from the dots menu: Screen Shot 2021-02-03 at 10 16 48 PM

The other thing to look at is whether the version of Dash that PyCharm sees is the same one you just upgraded. If for some reason PyCharm is pointing at a different Python installation than pip/easy_install, you might be looking at some old Dash installation. In the PyCharm Python console you can import dash and check dash.__version__

s3630237 commented 3 years ago

Thanks a lot Alex. I finally worked it out, here is the output. Plotly.version "1.38.0"

Furthermore, this is the output when I use the dash.version (dash 0.21.1 ). I don't understand why the package is old, as the interpreter is linking from Anaconda. As per my previous email, these packages are upgraded to the latest versions. Is my next course of action to re install PyCharm or is there a way to link my upgraded anaconda packages to PyCharm?

Cheers, Bill

From: Alex Johnson notifications@github.com Sent: Thursday, 4 February 2021 2:23 PM To: plotly/dash dash@noreply.github.com Cc: Bill Koutsovasilis s3630237@student.rmit.edu.au; Mention mention@noreply.github.com Subject: Re: [plotly/dash] Axes labels/titles not appearing (#539)

In the browser where you're viewing the dash app. If you're using Chrome this is "developer tools" from the dots menu: [Screen Shot 2021-02-03 at 10 16 48 PM]https://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F2678795%2F106840128-8728d280-666d-11eb-9dd1-e77e351f4bb3.png&data=04%7C01%7Cs3630237%40student.rmit.edu.au%7C69826f15a3bd46731be508d8c8bc2752%7Cd1323671cdbe4417b4d4bdb24b51316b%7C0%7C0%7C637480057738276669%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=xAZPsM0DV%2Fq5FEDauZD%2BcPoJPebzbWfPta%2B%2F7C5mteI%3D&reserved=0

The other thing to look at is whether the version of Dash that PyCharm sees is the same one you just upgraded. If for some reason PyCharm is pointing at a different Python installation than pip/easy_install, you might be looking at some old Dash installation. In the PyCharm Python console you can import dash and check dash.version

- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fplotly%2Fdash%2Fissues%2F539%23issuecomment-772998313&data=04%7C01%7Cs3630237%40student.rmit.edu.au%7C69826f15a3bd46731be508d8c8bc2752%7Cd1323671cdbe4417b4d4bdb24b51316b%7C0%7C0%7C637480057738286666%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=dbA9byNeAsUB57FboCS8jhmqMs1Dk79yOAGjTxRXpKc%3D&reserved=0, or unsubscribehttps://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAO2ZL3FLGXA7GEIPHMK3I63S5IHIRANCNFSM4GQF72EQ&data=04%7C01%7Cs3630237%40student.rmit.edu.au%7C69826f15a3bd46731be508d8c8bc2752%7Cd1323671cdbe4417b4d4bdb24b51316b%7C0%7C0%7C637480057738286666%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=YLqRI29J%2FzcC1hZuBrYfChcP57%2FlOhYfygreXziN3wU%3D&reserved=0.

s3630237 commented 3 years ago

Hi Alex,

I deleted the interpreter and then re added it within PyCharm. Thank you so much for your help. Its taken me ages to figure this out, and couldn't have done it without your help!

Cheers, Bill

From: Alex Johnson notifications@github.com Sent: Thursday, 4 February 2021 2:23 PM To: plotly/dash dash@noreply.github.com Cc: Bill Koutsovasilis s3630237@student.rmit.edu.au; Mention mention@noreply.github.com Subject: Re: [plotly/dash] Axes labels/titles not appearing (#539)

In the browser where you're viewing the dash app. If you're using Chrome this is "developer tools" from the dots menu: [Image removed by sender. Screen Shot 2021-02-03 at 10 16 48 PM]https://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F2678795%2F106840128-8728d280-666d-11eb-9dd1-e77e351f4bb3.png&data=04%7C01%7Cs3630237%40student.rmit.edu.au%7C69826f15a3bd46731be508d8c8bc2752%7Cd1323671cdbe4417b4d4bdb24b51316b%7C0%7C0%7C637480057738276669%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=xAZPsM0DV%2Fq5FEDauZD%2BcPoJPebzbWfPta%2B%2F7C5mteI%3D&reserved=0

The other thing to look at is whether the version of Dash that PyCharm sees is the same one you just upgraded. If for some reason PyCharm is pointing at a different Python installation than pip/easy_install, you might be looking at some old Dash installation. In the PyCharm Python console you can import dash and check dash.version

- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fplotly%2Fdash%2Fissues%2F539%23issuecomment-772998313&data=04%7C01%7Cs3630237%40student.rmit.edu.au%7C69826f15a3bd46731be508d8c8bc2752%7Cd1323671cdbe4417b4d4bdb24b51316b%7C0%7C0%7C637480057738286666%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=dbA9byNeAsUB57FboCS8jhmqMs1Dk79yOAGjTxRXpKc%3D&reserved=0, or unsubscribehttps://aus01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAO2ZL3FLGXA7GEIPHMK3I63S5IHIRANCNFSM4GQF72EQ&data=04%7C01%7Cs3630237%40student.rmit.edu.au%7C69826f15a3bd46731be508d8c8bc2752%7Cd1323671cdbe4417b4d4bdb24b51316b%7C0%7C0%7C637480057738286666%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=YLqRI29J%2FzcC1hZuBrYfChcP57%2FlOhYfygreXziN3wU%3D&reserved=0.

alexcjohnson commented 3 years ago

Great! Yeah it’s easy for pip and conda to point to complete different Python installations, and it’s best to just pick one and stick with it