mpld3

Saving interactive series on matplotlib figures (html)

依然范特西╮ 提交于 2021-01-28 04:54:29
问题 I have an example (from matplotlib) for an interactive plot where I can select from the series which lines I want to display on the plot. This works perfectly but now I want to export this to an html. I can successfully do this with mpld3.save_html() but lose the interactivity on the series selection. Here's the code import numpy as np import matplotlib.pyplot as plt, mpld3 from matplotlib.widgets import CheckButtons t = np.arange(0.0, 2.0, 0.01) s0 = np.sin(2*np.pi*t) s1 = np.sin(4*np.pi*t)

Why is this plot not displaying in template but works fine if URL is viewed directly in Django app?

喜欢而已 提交于 2020-01-24 21:49:26
问题 My problem I'm creating an interactive plot in my Django app. I have created a view for a plotting template and a view that generates only the plot itself so that I can use <img src= "{% url 'ozmod:plot' %}"/> to render the plot with the fancy plotting template. If I navigate to the URL I've assigned to the plotting template view I see a broken image link but the navbar and everything is extended fine. If I navigate directly to the URL for just the plot, the plot is displayed fine but, of

Python:TypeError: array([ 1.]) is not JSON serializable

喜欢而已 提交于 2020-01-13 05:50:36
问题 I want to convert the python plot in Html.I have taken reference example and I have changed it to convert plot to Html page.Below is my code: import matplotlib as plta plta.use('Agg') import matplotlib.pyplot as plt import numpy as np import mpld3 fig, ax = plt.subplots(subplot_kw=dict(axisbg='#EEEEEE')) N = 100 scatter = ax.scatter(np.random.normal(size=N), np.random.normal(size=N), c=np.random.random(size=N), s=1000 * np.random.random(size=N), alpha=0.3, cmap=plt.cm.jet) ax.grid(color=

Ipython notebook horizontal zoom

☆樱花仙子☆ 提交于 2019-12-24 12:15:27
问题 I have subplots in an ipython notebook. I can zoom in inline using the mpld3 module. However, right now I can only zoom into a rectangle. Due to my application's nature I need horizontal zoom. Is there a way to zoom horizontally (using your cursor) in matplotlib? Better yet can I set the zoom to be horizontal via code without any keyboard manipulation? In Matlab, I can do this by setting: figure(1); h=zoom; set(h,'Motion','horizontal','Enable','on'); Here is a minimal example in python:

Python: float() argument must be a string or a number,not 'pandas

醉酒当歌 提交于 2019-12-24 08:06:20
问题 Have the following piece of code through which I am trying to plot a graph: import pandas as pd import numpy as np import matplotlib.pyplot as plt import mpld3 my_list = [1,2,3,4,5,7,8,9,11,23,56,78,3,3,5,7,9,12] new_list = pd.Series(my_list) df1 = pd.DataFrame({'Range1':new_list.value_counts().index, 'Range2':new_list.value_counts().values}) df1.sort_values(by=["Range1"],inplace=True) df2 = df1.groupby(pd.cut(df1["Range1"], [0,1,2,3,4,5,6,7,8,9,10,11,df1['Range1'].max()])).sum() objects =

Vertical line axvline plots line in wrong position in loglog plot in matplotlib

坚强是说给别人听的谎言 提交于 2019-12-24 04:09:07
问题 I have a problem using axvline to plot vertical lines in the loglog plot of matplotlib. The first problem is that the vertical lines do not appear at the right location. The second problem, possibly related is that when I zoom in or translate the plot, the vertical lines just stay in place and are not appropriately transformed by the translation (sliding the plot) or zooming into to the plot. My code looks as follows: import numpy as np import matplotlib.pyplot as plt f, axes = plt.subplots(1

mpld3: How to change the location of the toolbar using a plugin?

徘徊边缘 提交于 2019-12-24 00:20:06
问题 The toolbar for mpld3 displays is usually located in the bottom right corner of the screen. I would like it to be in the top-right corner of the screen. It appears as though the code controlling the position of the toolbar can be located here. I would like to know how to select the toolbar object using Javascript so that I may change it's location. The Javascript code would ideally be the attribute of some custom mpld3 plugin. 回答1: Here is a simple mpld3 plugin to move the toolbar to the top

How to “dump” points selected with the LinkedBrush plugin for mpld3?

 ̄綄美尐妖づ 提交于 2019-12-20 01:12:10
问题 I am trying to implement a plugin that allows the user to dump relevant information about points selected by the LinkedBrush plugin. I think my question is sort of related to this example. I have meta information tied to each point via the HTMLTooltip plugin. Ideally, I would somehow be able to dump this too. In the example I linked to, the information is outputted via a prompt. I wish to be able to save this information to a text file of some kind. Put slightly differently: How do I

mpld3 ~ Select points and get their coordinates?

限于喜欢 提交于 2019-12-12 03:17:43
问题 Is it possible to use mpld3 to select certain points on a graph, and then get the coordinates of those points? For example, here you can select points with a rectangle, which dynamically updates other subplots, is there any way to get the identity of selected points into python? http://mpld3.github.io/examples/linked_brush.html 来源: https://stackoverflow.com/questions/33108218/mpld3-select-points-and-get-their-coordinates

mpld3 plot, annotations issues

﹥>﹥吖頭↗ 提交于 2019-12-10 18:42:19
问题 I'm using mpld3 to display graphs on an intranet website. I'm using the option of saving the graph to a dict and render it on the client side using mpld3.js. The graph renders fine except when I want to use annotations. Those ones are clearly offset. And I don't understand why, because even if I set the offset to (0, 0), the annotations are still way off. To illustrate this, I have copied and pasted the example given in this post: Matplotlib: How to put individual tags for a scatter plot Here