Supplies plotting functionalities for dashboards
p = barplot(np.array([10, 20]), np.array(["labelA", "labelB"]))
pn.Row(p)
hist = [[1, 10], [2, 20]]
p = barplot([np.array([10, 20]), np.array([10, 20]), np.array([10, 20])], [np.array([1, 2]), np.array([1, 2]), np.array([1, 2])], bar_type="vertical")
pn.Row(*p)
hist = [[1, 10], [2, 20]]
p = barplot([np.array([10, 20]), np.array([10, 20]), np.array([10, 20])], [np.array([1, 2]), np.array([1, 2]), np.array([1, 2])], bar_type="horizontal", linked_axis=False)
pn.Row(*p)
with pytest.raises(ValueError):
hist = [[1, 10], [2, 20]]
p = barplot([np.array([10, 20]), np.array([10, 20]), np.array([10, 20])], [np.array([1, 2]), np.array([1, 2]), np.array([1, 2])], bar_type="false", linked_axis=False)
with pytest.raises(TypeError):
hist = [[1, 10], [2, 20]]
p = barplot(None, bar_type="false", linked_axis=False)
pn.Row(histogram(np.array([1,1,1,2,2,2,2,3,3,4]), bins=4, range=(1,4), density=True, title="test", orientation="vertical", x_label="test", y_label="y_label"))
pn.Row(histogram(np.array([1,1,1,2,2,2,2,3,3,4]), bins=4, range=(1,4), density=True, title="test", orientation="horizontal", remove_tools=True))
pn.Row(*histogram([np.array([1,1,1,1,2,2,2,3,3,4]), np.array([1,2,2,2,2,2,2,3,3,4]), np.array([1,1,5,5,5,5,2,3,3,4])], title=["a", "b", "c"], bins=4, range=(1,4), density=True))
pn.Row(*histogram([np.array([1,1,1,1,2,2,2,3,3,4]), np.array([1,2,2,2,2,2,2,3,3,4]), np.array([1,1,5,5,5,5,2,3,3,4])], title=["a", "b", "c"], bins=4, range=(1,4), density=True, orientation="vertical"))
with pytest.raises(TypeError):
histogram(None)
test_df = pd.DataFrame({"filepath": ["fileA", "fileA", "fileA", "fileB", "fileB", "fileC", "fileC", "fileC"], "label": [1, 2, 1, 2, 3, 3, 1, 2]})
test_mixing_matrix_df = calculate_mixing_matrix(test_df, "filepath", "label")
pn.Column(heatmap(test_mixing_matrix_df, "row_name", "col_name", "values", normalize="None"))
test_df = pd.DataFrame({"filepath": ["fileA", "fileA", "fileA", "fileB", "fileB", "fileC", "fileC", "fileC"], "label": [1, 2, 1, 2, 3, 3, 1, 2]})
test_mixing_matrix_df = calculate_mixing_matrix(test_df, "filepath", "label")
pn.Column(heatmap(test_mixing_matrix_df, "row_name", "col_name", "values", normalize="Column"))
test_df = pd.DataFrame({"filepath": ["fileA", "fileA", "fileA", "fileB", "fileB", "fileC", "fileC", "fileC"], "label": [1, 2, 1, 2, 3, 3, 1, 2]})
test_mixing_matrix_df = calculate_mixing_matrix(test_df, "filepath", "label")
test_mixing_matrix_df_high = test_mixing_matrix_df.copy()
test_mixing_matrix_df_high["values"] *= 5
pn.Row(*heatmap([test_mixing_matrix_df, test_mixing_matrix_df_high, test_mixing_matrix_df], "row_name", "col_name", "values", normalize="Row", link_plots=False))
test_df = pd.DataFrame({"filepath": ["fileA", "fileA", "fileA", "fileB", "fileB", "fileC", "fileC", "fileC"], "label": [1, 2, 1, 2, 3, 3, 1, 2]})
test_mixing_matrix_df = calculate_mixing_matrix(test_df, "filepath", "label")
test_mixing_matrix_df_high = test_mixing_matrix_df.copy()
test_mixing_matrix_df_high["values"] *= 5
pn.Row(*heatmap([test_mixing_matrix_df, test_mixing_matrix_df_high, test_mixing_matrix_df], "row_name", "col_name", "values", normalize="Row", link_plots=True))
with pytest.raises(TypeError):
heatmap(None)
start_date = datetime.date(2020, 1, 1)
test_date_df = pd.DataFrame({"creation_date": [start_date]*10})
test_date_df["modification_date"] = test_date_df["creation_date"] + pd.Series([datetime.timedelta(days=np.random.randint(1, 101)) for _ in range(test_date_df.shape[0])])
test_date_df["creation_date"] = pd.to_datetime(test_date_df["creation_date"])
test_date_df["modification_date"] = pd.to_datetime(test_date_df["modification_date"])
pn.Row(time_arc_plot(test_date_df["creation_date"], test_date_df["modification_date"]))
test_df = pd.DataFrame({"dataset_name": ["test_name"], "num_images": [50], "num_annotation": [75]})
pn.Row(table_from_dataframe(test_df, width=1000))
test_df = pd.DataFrame({"dataset_name": ["test_name"], "num_images": [50], "num_annotation": [75]})
pn.Column(*table_from_dataframe([test_df, test_df, test_df], width=1000))
test_data = pd.DataFrame({"class": ["a","b","c","a","a","b","c","a","c","b"], "obj_on_img": [1,1,1,2,2,2,3,3,3,3]})
pn.Row(stacked_hist(test_data, "obj_on_img", "class", x_label="Obj. per Img"))
test_data_1 = pd.DataFrame({"class": ["a","b","c","a","a","b","c","a","c","b"], "obj_on_img": [1,1,1,2,2,2,3,3,3,3]})
test_data_2 = pd.DataFrame({"class": ["a","b","c","a","a","b","c","a","c","b"], "obj_on_img": [2,3,3,3,3,3,3,3,3,3]})
pn.Row(*stacked_hist([test_data_1, test_data_2], "obj_on_img", "class", x_label="Obj. per Img", link_plots=False))
Creates a 2d histogram where each row represents a category and each category is histogramed over the x-axis. There are two options for the x-axis, it can be set to categroical (hist_col_is_categorical = True
) in this case the values of the hist_col
will not be histogramed but each unique value will be a seperate bin.
pn.Row(categorical_2d_histogram(test_data, "obj_on_img", "obj_on_img", hist_col_is_categorical=False))
pn.Row(*categorical_2d_histogram([test_data, test_data, test_data], "obj_on_img", "obj_on_img", hist_col_is_categorical=True))
categorical_2d_histogram_with_gui(test_data)
categorical_2d_histogram_with_gui([test_data, test_data])
test_df = pd.DataFrame({"a": np.random.randint(0, 100, 10), "b": np.random.randint(0, 100, 10), "c": np.random.randint(0, 100, 10), "color_a": [1,2,3,1,1,1,2,3,1,2], "color_b": [1,3,3,3,2,2,2,3,1,1]})
scatter_plot_with_gui(test_df, x_cols=["a", "b", "c"], y_cols=["a", "b", "c"])
test_df = pd.DataFrame({"a": np.random.randint(0, 100, 10), "b": np.random.randint(0, 100, 10), "c": np.random.randint(0, 100, 10), "color_a": [1,2,3,1,1,1,2,3,1,2], "color_b": [1,3,3,3,2,2,2,3,1,1]})
scatter_plot_with_gui(test_df, x_cols=["a", "b", "c"], y_cols=["a", "b", "c"], color_cols=["color_a", "color_b"])
hists = [histogram(np.array(np.random.randint(0, 100, 1000)), bins=4, range=(1,4), density=True) for i in range(10)]
plots_as_matrix(hists, 3, 4, width=1000, height=1000)