Wow, it was amazing... was trying to make a treemap at work and spent an entire afternoon at Google - then I found out this video and boom, in less than 30 minutes it was great. I am looking forward for your book!!! Keep up with the good work
Bro, I really appreciate your hardwork, and your helpful contents. Your tutorials are just perfect and in detail. I have learnt a lot from your tutorials, and I genuinely love all of the contents. Thanks bro
Great Tutorial! For me it was 98% of time spend on cleaning the data from my own Excel file and 2% of fun with modyfing the sunburst. It is very cool and useful tutorial!
Love the channel, been a lifesaver more than once. I do have a quick q though, when I try and load the sunburst graph using dash it just loads a whitescreen (with the title and colorbar), even though the same plot works perfectly in Jupyter Notebooks. Weirdly enough it will work in Dash if I change the branchvalues parameter to 'remainder' instead of 'total', but I need to keep it as total. You have any idea how this would happen? Thanks again for the tutoirals.
hi @Joe, Thanks for the compliments. I'm not sure what's going on. Maybe it's a version control problem. What version of Dash are you using when working with Jupyter, and what version of Dash do you use when working with a Python IDE?
@Charming Data Hi I have another question :) In the challenge problem, how does plotly determine the color of the inner wedges that aren't male/female?
Great tutorial! It's been so helpful for me at work to visualise a complicated spreadsheet. One point that I have noticed with my own sunburst, and with some of yours, often the total percentage doesn't add to 100%, going instead to either 99% or 101%. I assume this is a rounding error but do you know a quick fix for this to guarantee 100% every time? Thanks again for your great tutorial.
Hi Adam , thanks for such nice detailed tutorial. I am following each tutorial and learning fast . But is it possible to you to have a video on “chained callbacks” and “theme” in dash. Thanks in advance 🙏
Charming Data Hi Adam, exactly what i mean. I am trying to create callbacks in which pattern can be used to create dynamic UIs where one input component updates the available options of the next input component.
@@adityajawla723 ok. That's better to do with pattern matching callbacks. I hope to post a tutorial about this next week. In the meantime, this is a good read that might help you: dash.plotly.com/pattern-matching-callbacks
Hi Adam, thanks for the tutorial. Your series on Plotly is by far the best I could find for free or paid. There something interesting I found here though. I was running this code through on Google colab and colab promptly errored out saying "TypeError: sunburst() got an unexpected keyword argument 'path'". This is weird as its literally used again and again in the documentation. When I tried to run other code snippets in the documentation on colab it gave the exact same error with sunburst chart. All this code works perfectly fine on my local machine though. If the chart type is unsupported on colab shouldn't it say that instead of giving these kind of error messages? Any idea why this is happening
That's very interesting, @Anup. Maybe you found some kind of incompatibility between Plotly and Google colab. Maybe using the parameter "path" is not compatible with the way Google writes its code. It's so wierd. Thanks for sharing.
Thanks a lot, Adam! However, I am still having difficulties with: 1. hover_data - whenever I try to select a specific label to change it to false I am getting "keyword argument repeated"? 2. giving a specific color to root - when the "Color" field is set to one of the branches and not the root. 3. Do you believe there's a way i could have multiple sunburst charts plot in one row as appose to them being showing in different rows?
Hi @Chavya. It's hard to say without seeing the code. Feel free to send me your code, error message, and line of code where the error appears to info@charmingdata.org
@@CharmingData Thanks, Adam! done, sent an email - I've also included the recent question I asked about displaying multiple sunburst charts in the same row, hope you could guide me on that one too. Thanks a lot for taking your time :)
Hi, could you please explain how to deal with labels parameter? I have a boolean column and want to show other strings instead of True or False. Thanks a lot
Hi @emionok, If I understand your question correctly, you can do labels={"True": "red", "False": "blue"}. The labels parameter is used to changed the labels on the graph, specifically those labels that are being plotted like x axis and y axis. They usually refer to column names and not data in each row. If you need to change the row data from True/False to string , then just convert the data with pandas. Create a new column that will assign 'blue' to row 1 if row 1 of Boolean column is False, and the same with the True data.
@@CharmingData Thank you for your prompt reply. Do you know is there a possibility to change labels on sunburst? this way - labels={"True": "red", "False": "blue"} doesn't work. Thank you in advance
@@emionok probably not because the labels parameter would change the x or y labels, not the data points inside the axis. That's why you should create another column that has the new strings you are looking for. And plot that column. That didn't work for you?
@@emionok I'm glad you got it, @emionok. Hope you create many powerful dashboards 💪 . If you need help in the future, let me know. And if you'd like to support my channel, I would be grateful to you🙏 ruclips.net/channel/UCqBFsuAz41sqWcFjZkqmJqQjoin
@@CharmingData Yup I ran your code copying from github. Also, the challenge file doesn't work for me. It says it expects "id" and "label" as a column in the dataframe. If I run the code with only {"Victim's Gender":"False"} it works. Not sure if this is a problem in my PyCharm or something. What do you think? Thanks for your help, really appreciate you making this tutorial and answering questions :)
@@CK-qh5te Hi Chris, I'm not sure what's wrong. Perhaps it's the plotly of Dash version you're using, because I just ran the challenge_solution file on my computer and it worked.
@@CharmingData it seems they don't allow adding stackoverflow links here. I asked the Q there but I have't received any response so far. In the tree map, or icicle map, I want to order one of the child variables.
@@CharmingData I would like to reorder the days of the week to appear in order: Thursday, Friday, and Sunday. How do you change that in plotly treemap? I appreciate your kind help. import plotly.express as px df = px.data.tips() fig = px.treemap(df, path=[px.Constant("all"), 'sex', 'day', 'time'], values='total_bill', color='time') fig.update_layout(margin = dict(t=50, l=25, r=25, b=25)) fig.show()
@@r_pydatascience HI, I think for the sunburst, you can use fig.update_traces(sort=False), and then you can order the data at your end, in the direction desired. Or you can probably build the sunburst with Plotly GO. That could give you more control over the order of the root
@@CharmingData Thanks again, bro! I also thought adding fig.update_traces(sort=False) would do the job but it didn't order it with the natural order of the weeks(Thursday, Friday, Saturday, Sunday). I think that is probably done with a dictionary but I didn't manage to make it work.
Hey Everyone. Here's the Challenge Solution. Let me know if you have any questions. Good luck: github.com/Coding-with-Adam/Dash-by-Plotly/blob/master/Plotly_Graphs/Sunburst/solution_challenge.py
your hard work is boon for us
Your tutorials on Plotly are just awesome! Thanks for sharing! 👌🎉
You're welcome, @Amin. Let me know of you have questions with anything
Wow, it was amazing... was trying to make a treemap at work and spent an entire afternoon at Google - then I found out this video and boom, in less than 30 minutes it was great.
I am looking forward for your book!!! Keep up with the good work
Thank you Rafael
Bro, I really appreciate your hardwork, and your helpful contents. Your tutorials are just perfect and in detail. I have learnt a lot from your tutorials, and I genuinely love all of the contents. Thanks bro
Thank you for watching 🤗
Bro, We can't thank you enough for such great content; Keep up the awesome work 😊
Great Tutorial! For me it was 98% of time spend on cleaning the data from my own Excel file and 2% of fun with modyfing the sunburst. It is very cool and useful tutorial!
Thank you
Excellent tutorial, thank u so much !
Quality content ! Thank you kindly < 3
excellent video tutorial, I'll be glad to share it around, is very well done, congrats again
Love the channel, been a lifesaver more than once.
I do have a quick q though, when I try and load the sunburst graph using dash it just loads a whitescreen (with the title and colorbar), even though the same plot works perfectly in Jupyter Notebooks. Weirdly enough it will work in Dash if I change the branchvalues parameter to 'remainder' instead of 'total', but I need to keep it as total. You have any idea how this would happen?
Thanks again for the tutoirals.
hi @Joe, Thanks for the compliments. I'm not sure what's going on. Maybe it's a version control problem. What version of Dash are you using when working with Jupyter, and what version of Dash do you use when working with a Python IDE?
@Charming Data Hi I have another question :) In the challenge problem, how does plotly determine the color of the inner wedges that aren't male/female?
Figured this out in documentation for anyone who is interested "the first color of the discrete color sequence is used"
@@CK-qh5te thanks for sharing, Chris
Great tutorial! It's been so helpful for me at work to visualise a complicated spreadsheet.
One point that I have noticed with my own sunburst, and with some of yours, often the total percentage doesn't add to 100%, going instead to either 99% or 101%. I assume this is a rounding error but do you know a quick fix for this to guarantee 100% every time?
Thanks again for your great tutorial.
Thanks for watching, Ben. I agree. It's probably a rounding error, but I'm not sure how to fix that.
Awesome!!!
Hi Adam , thanks for such nice detailed tutorial. I am following each tutorial and learning fast . But is it possible to you to have a video on “chained callbacks” and “theme” in dash. Thanks in advance 🙏
Hi Aditya, when you say "chained callbacks", are you referring to Pattern-Matching Callbacks and basic callbacks?
dash.plotly.com/basic-callbacks
Charming Data Hi Adam, exactly what i mean. I am trying to create callbacks in which pattern can be used to create dynamic UIs where one input component updates the available options of the next input component.
@@adityajawla723 ok. That's better to do with pattern matching callbacks. I hope to post a tutorial about this next week. In the meantime, this is a good read that might help you: dash.plotly.com/pattern-matching-callbacks
Great! :)
OMG THIS IS BRILLIANT!!! THANK YOU SO MUCH!
I have an additional question: is it possible to also add/display the percent entry into the hoverdata?
Hi Adam, thanks for the tutorial. Your series on Plotly is by far the best I could find for free or paid.
There something interesting I found here though. I was running this code through on Google colab and colab promptly errored out saying "TypeError: sunburst() got an unexpected keyword argument 'path'". This is weird as its literally used again and again in the documentation. When I tried to run other code snippets in the documentation on colab it gave the exact same error with sunburst chart. All this code works perfectly fine on my local machine though.
If the chart type is unsupported on colab shouldn't it say that instead of giving these kind of error messages? Any idea why this is happening
That's very interesting, @Anup. Maybe you found some kind of incompatibility between Plotly and Google colab. Maybe using the parameter "path" is not compatible with the way Google writes its code.
It's so wierd. Thanks for sharing.
Thanks a lot, Adam! However, I am still having difficulties with:
1. hover_data - whenever I try to select a specific label to change it to false I am getting "keyword argument repeated"?
2. giving a specific color to root - when the "Color" field is set to one of the branches and not the root.
3. Do you believe there's a way i could have multiple sunburst charts plot in one row as appose to them being showing in different rows?
Hi @Chavya. It's hard to say without seeing the code. Feel free to send me your code, error message, and line of code where the error appears to info@charmingdata.org
@@CharmingData Thanks, Adam! done, sent an email - I've also included the recent question I asked about displaying multiple sunburst charts in the same row, hope you could guide me on that one too.
Thanks a lot for taking your time :)
@@rohanplaylist3843 got it. I'll take a look tomorrow or Monday. A big busy recording the next tutorial.
@@CharmingData Thank you Adam! i really appreciate you taking time to assist.
Hi, could you please explain how to deal with labels parameter? I have a boolean column and want to show other strings instead of True or False. Thanks a lot
Hi @emionok,
If I understand your question correctly, you can do labels={"True": "red", "False": "blue"}. The labels parameter is used to changed the labels on the graph, specifically those labels that are being plotted like x axis and y axis. They usually refer to column names and not data in each row.
If you need to change the row data from True/False to string , then just convert the data with pandas. Create a new column that will assign 'blue' to row 1 if row 1 of Boolean column is False, and the same with the True data.
@@CharmingData Thank you for your prompt reply. Do you know is there a possibility to change labels on sunburst? this way - labels={"True": "red", "False": "blue"} doesn't work. Thank you in advance
@@emionok probably not because the labels parameter would change the x or y labels, not the data points inside the axis. That's why you should create another column that has the new strings you are looking for. And plot that column.
That didn't work for you?
@@CharmingData Thank, that definitely works, I just don't understand how the label parameter works in px.sunburst :)
@@emionok I'm glad you got it, @emionok. Hope you create many powerful dashboards 💪 . If you need help in the future, let me know. And if you'd like to support my channel, I would be grateful to you🙏
ruclips.net/channel/UCqBFsuAz41sqWcFjZkqmJqQjoin
For some reason the legend doesn't show up for me when I do the color scale sunburst chart. Is there a way to turn this on?
I tried "fig.update_layout(showlegend=True)" also but this didn't work either
@@CK-qh5te are you using the same code in using?
@@CharmingData Yup I ran your code copying from github.
Also, the challenge file doesn't work for me. It says it expects "id" and "label" as a column in the dataframe. If I run the code with only {"Victim's Gender":"False"} it works. Not sure if this is a problem in my PyCharm or something. What do you think?
Thanks for your help, really appreciate you making this tutorial and answering questions :)
@@CK-qh5te Hi Chris, I'm not sure what's wrong. Perhaps it's the plotly of Dash version you're using, because I just ran the challenge_solution file on my computer and it worked.
@@CharmingData Hm strange, I'll post on the plotly forum. I have plotly 4.14.3 and plotly express 0.4.1. Thanks!
Is it possible to reorder the variables in the sectors of the sunburst plot?
Hi @R_py, I don't think so but I'll try to search more. What part of the sunburst would you like to reorder?
@@CharmingData it seems they don't allow adding stackoverflow links here. I asked the Q there but I have't received any response so far. In the tree map, or icicle map, I want to order one of the child variables.
@@CharmingData I would like to reorder the days of the week to appear in order: Thursday, Friday, and Sunday. How do you change that in plotly treemap? I appreciate your kind help.
import plotly.express as px
df = px.data.tips()
fig = px.treemap(df, path=[px.Constant("all"), 'sex', 'day', 'time'],
values='total_bill', color='time')
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
fig.show()
@@r_pydatascience HI, I think for the sunburst, you can use fig.update_traces(sort=False), and then you can order the data at your end, in the direction desired. Or you can probably build the sunburst with Plotly GO. That could give you more control over the order of the root
@@CharmingData Thanks again, bro! I
also thought adding fig.update_traces(sort=False) would do the job but it didn't order it with the natural order of the weeks(Thursday, Friday, Saturday, Sunday). I think that is probably done with a dictionary but I didn't manage to make it work.
Hey Everyone. Here's the Challenge Solution. Let me know if you have any questions. Good luck: github.com/Coding-with-Adam/Dash-by-Plotly/blob/master/Plotly_Graphs/Sunburst/solution_challenge.py
Hey, can you do a video on an actual treemap
How Robert. Thanks for watching. I'll take a look and see. Was this sunburst tutorial helpful for you?