コード例 #1
0
ファイル: test_xrview.py プロジェクト: phausamann/xrview
    def test_options(self):
        """"""
        plot = xrview.plot(self.data, x="sample")
        assert isinstance(plot, HtmlPlot)

        # TODO implement
        with self.assertRaises(NotImplementedError):
            xrview.plot(self.data, x="sample", server=True)

        plot = xrview.plot(self.data, x="sample", output="notebook")
        assert isinstance(plot, NotebookPlot)

        plot = xrview.plot(self.data,
                           x="sample",
                           output="notebook",
                           server=True)
        assert isinstance(plot, NotebookViewer)

        plot = xrview.plot(self.data,
                           x="sample",
                           output="notebook",
                           server=True,
                           resolution=1)
        assert isinstance(plot, NotebookTimeseriesViewer)
コード例 #2
0
ファイル: minimal_example.py プロジェクト: phausamann/xrview
import numpy as np
import xarray as xr
from bokeh.plotting import show

import xrview

x = np.linspace(0, 1, 100)
y = np.sqrt(x)
da = xr.DataArray(y, coords={"x": x}, dims="x")

plot = xrview.plot(da, x="x")

# plot.show() doesn't work in sphinx
show(plot.make_layout())
コード例 #3
0
ファイル: test_xrview.py プロジェクト: phausamann/xrview
 def test_html_plot(self):
     """"""
     plot = xrview.plot(self.data, x="sample")
     plot.show()
コード例 #4
0
ファイル: add_figure.py プロジェクト: phausamann/xrview
import numpy as np
import xarray as xr
from bokeh.plotting import show

import xrview

x = np.linspace(0, 1, 100)
y = np.vstack([np.sqrt(x), x, x**2]).T
ds = xr.Dataset(
    {
        "Clean": (["x", "f"], y),
        "Noisy": (["x", "f"], y + 0.01 * np.random.randn(100, 3)),
    },
    coords={
        "x": x,
        "f": ["sqrt(x)", "x", "x^2"]
    },
)

plot = xrview.plot(ds, x="x", ncols=2)

da = xr.DataArray(np.ones(20), {"x": np.linspace(0, 1, 20)}, "x")
plot.add_figure(da)

# plot.show() doesn't work in sphinx
show(plot.make_layout())
コード例 #5
0
import numpy as np
import xarray as xr
from bokeh.plotting import show

import xrview

x = np.linspace(0, 1, 100)
y = np.vstack([np.sqrt(x), x, x**2]).T
ds = xr.Dataset(
    {
        "Clean": (["x", "f"], y),
        "Noisy": (["x", "f"], y + 0.01 * np.random.randn(100, 3)),
    },
    coords={
        "x": x,
        "f": ["sqrt(x)", "x", "x^2"]
    },
)

plot = xrview.plot(ds, x="x", ncols=2, overlay="data_vars")

# plot.show() doesn't work in sphinx
show(plot.make_layout())
コード例 #6
0
ファイル: composite_glyphs.py プロジェクト: phausamann/xrview
    y,
    dims=(["x", "f"]),
    coords={
        "x": x,
        "f": ["sqrt", "lin", "square"],
        "sin": ("x", c),
        "lower": (["x", "f"], y - 0.5),
        "upper": (["x", "f"], y + 0.5),
        "q_lower": (["x", "f"], y - 0.25),
        "q_upper": (["x", "f"], y + 0.25),
    },
)

da = da[::10].stack(z=("x", "f"))

plot = xrview.plot(
    da,
    x="z",
    coords=True,
    y_range=(-0.5, 1.5),
    glyphs=BoxWhisker(0.8, "q_lower", "lower", "q_upper", "upper", color="f"),
)

plot.modify_figures({
    "xgrid.visible": False,
    "xaxis.major_label_orientation": np.pi / 2
})

# plot.show() doesn't work in sphinx
show(plot.make_layout())
コード例 #7
0
import numpy as np
import xarray as xr
from bokeh.plotting import show

import xrview
from xrview.glyphs import Square

x = np.linspace(0, 1, 100)
y = np.sqrt(x)

da_sqrt = xr.DataArray(y, {"x": x}, "x")
da_const = xr.DataArray(np.ones(20), {"x": x[::5]}, "x")

plot = xrview.plot(da_sqrt, x="x", glyphs="circle")
plot.add_overlay(da_const, glyphs=["line", Square(color="red")])

# plot.show() doesn't work in sphinx
show(plot.make_layout())