Plot fixes (#1044)

* matplotlib and warning fix

* fix matplotlib demo
This commit is contained in:
Dawood Khan 2022-04-20 15:14:46 -04:00 committed by GitHub
parent d7b8b03267
commit 76eab3f9ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 7 deletions

View File

@ -29,7 +29,7 @@ def outbreak(plot_type, r, month, countries, social_distancing):
if plot_type == "Matplotlib":
fig = plt.figure()
plt.plot(df['day'], df[countries])
plt.plot(df['day'], df[countries].to_numpy())
plt.title("Outbreak in " + month)
plt.ylabel("Cases")
plt.xlabel("Days since Day 0")

View File

@ -1130,7 +1130,7 @@ class Image(Component):
"""
if "plot" in kwargs:
warnings.warn(
"The 'plot' parameter has been deprecated. Set parameter 'type' to 'plot' instead.",
"The 'plot' parameter has been deprecated. Use the new Plot() component instead",
DeprecationWarning,
)
self.type = "plot"

View File

@ -22,9 +22,9 @@
const bokehPromises = Array(6).fill(0).map((_, i) => createPromise(i))
const initializeBokeh = (index) => {
if (value["type"] == "bokeh") {
if (value && value["type"] == "bokeh") {
resolves[index]()
}
}
}
function createPromise(index) {
@ -50,17 +50,18 @@
let plotDiv = document.getElementById("plotlyDiv");
Plotly.newPlot(plotDiv, plotObj["data"], plotObj["layout"]);
} else if (value && value["type"] == "bokeh") {
document.getElementById("bokehDiv").innerHTML = "";
let plotObj = JSON.parse(value["plot"]);
window.Bokeh.embed.embed_item(plotObj, "bokehDiv");
window.Bokeh.embed.embed_item(plotObj, "bokehDiv");
}
});
</script>
{#if value && value["type"] == "plotly"}
<div id="plotlyDiv"/>
{:else if value}
<div id="bokehDiv"/>
{:else if value && value["type"] == "bokeh"}
<div id="bokehDiv"/>
{:else if value && value["type"] == "matplotlib"}
<div
class="output-image w-full h-80 flex justify-center items-center dark:bg-gray-600 relative"
{theme}