plotly

How to plot normal distribution with percentage of data as label in each band/bin?

寵の児 提交于 2020-01-13 04:31:10
问题 While plotting normal distribution graph of data, how can we put labels like in image below for percentage of data in each bin where each band has a width of 1 standard deviation using matplotlib/seaborn or plotly ? Currently, im plotting like this: hmean = np.mean(data) hstd = np.std(data) pdf = stats.norm.pdf(data, hmean, hstd) plt.plot(data, pdf) 回答1: Although I've labelled the percentages between the quartiles, this bit of code may be helpful to do the same for the standard deviations.

How to plot normal distribution with percentage of data as label in each band/bin?

霸气de小男生 提交于 2020-01-13 04:31:06
问题 While plotting normal distribution graph of data, how can we put labels like in image below for percentage of data in each bin where each band has a width of 1 standard deviation using matplotlib/seaborn or plotly ? Currently, im plotting like this: hmean = np.mean(data) hstd = np.std(data) pdf = stats.norm.pdf(data, hmean, hstd) plt.plot(data, pdf) 回答1: Although I've labelled the percentages between the quartiles, this bit of code may be helpful to do the same for the standard deviations.

Legend title in plotly

血红的双手。 提交于 2020-01-13 02:44:11
问题 How do I specify title for legend in plotly ? I have a stacked bar graph that plots different durations like 0-10, 11-20. I want the legend title to say 'Duration'. 回答1: The simplest way to specify a legend title is to set it via ggplot and have plotly read it from the corresponding object: library( plotly ) gg <- ggplot( mtcars, aes( x=mpg, y=wt, color=factor(vs) ) ) + geom_point() + labs( color = "MyTitle" ) ggplotly( gg ) However, the problem is that plotly converts the legend title into

Plotly offline with flask

邮差的信 提交于 2020-01-12 02:34:33
问题 How can I use plotly offline with flask . I know that plotly can be used offline with Ipython notebook , Can I use Plotly offline with flask ? If not , can someone please suggest which python library can I use for 3 D visualisation in flask (offline library) 回答1: What you want to do is make functions that return the offline "plot" result as a html <div> . To do this, you call the offline.plot() method with the output_type="div" argument. This will return a pure string that you can then put in

Cx_Freeze and Plotly

孤人 提交于 2020-01-11 14:07:43
问题 I am trying to build an exe of an application that uses plotly using cx_freeze. I have previously built the application using matplotlib but have switched the graphing over to plotly. I can build the application but when I try to plot, I get the following error. url = py.plot(fig, filename='pandas-box-plot') File "C:\Python34\lib\site-packages\plotly\offline\offline.py", line 284, in p lot get_plotlyjs(), File "C:\Python34\lib\site-packages\plotly\offline\offline.py", line 48, in ge t

Plotly: How do the buttons for the update menus really work?

放肆的年华 提交于 2020-01-11 13:34:27
问题 Why do I want to know? This may seem like a very simple question, but I'm having some difficulties editing figures with multiple traces using dropdownmenus, so I'm really eager to make sure that I'm understanding the inner workings of plotlys dropdown menus, update menus and buttons 100% correct. So it would be great if someone could find the time to take a look at the example below. What is the problem? Consider the following simple plotly figure produced by the code snippet below: Plot1 :

Adding drop down menu to Choropleth map to select each state and generate new graph type

一笑奈何 提交于 2020-01-11 07:17:22
问题 I've created a Choropleth map and I want to know if it's possible to add a drop down with each state. When you select the drop down the graph changes to a line graph of the number of Bachelor degrees earned over time in that state. A sample of my data: year state statetotal ba_total 0 1984.0 AK 221.0 108.0 1 1985.0 AK 242.0 141.0 2 1984.0 NC 229.0 117.0 3 1985.0 NC 257.0 138.0 4 1984.0 MA 272.0 165.0 5 1985.0 MA 280.0 176.0 6 1984.0 NY 375.0 249.0 7 1985.0 NY 309.0 208.0 This is what I've

event when clicking a name in the legend of a plotly's graph in R Shiny

孤街醉人 提交于 2020-01-11 06:52:07
问题 I want to display some information when the user click on the legend of a plotly graph. For example in the code below, if the user clicks on the "drat" name in the legend to unshow these data, I would like to print a text saying "drat and qsec are selected". I have seen this stackoverflow's post: R shiny and plotly getting legend click events but it works with labels. In my case, labels is not an available parameter. I have tested the different plotly events but none return any information

Saving Dash layout to html

拥有回忆 提交于 2020-01-11 04:21:08
问题 I plotted a bunch of things in a dash layout. I want to save them to an html file so I can look at them later. when I reopen the saved html file, I first see everything correctly. However, within <1s, the page goes blank and I get an error: “Error loading layout”. (see gif below) How can this be fixed? Thanks! 回答1: This solution is not fully working: You have to save your Webpage complete. To prevent the javascript creating any errors i have removed the bundle(2).js file. This file contains

Embedding plotly output in R markdown

被刻印的时光 ゝ 提交于 2020-01-10 20:04:46
问题 There is a blog entry which describes embedding from the plotly API for R into R markdown. I just used the code to create the iframe for an html document When I have the prieview in R studio there is no error message and the iframe is created in the html document. However, it is just empty. Apparently it does not load the content somehow. I did not create the plot in the R API beforehand (but that should not matter as this is just embedding a picture into html) isn't it? My code in r markdown