Supplies plotting functionalities for dashboards
INFO     - The mmdet config folder already exists. No need to downloaded it. Path : /home/frederik/.icevision/mmdetection_configs/mmdetection_configs-2.16.0/configs | icevision.models.mmdet.download_configs:download_mmdet_configs:17

barplot[source]

barplot(counts:Union[ndarray, List[ndarray]], values:Union[ndarray, List[ndarray]], bar_type:Union[ForwardRef('horizontal'), ForwardRef('vertical')]='horizontal', linked_axis=True, width:int=500, height:int=500, **kwargs)

Creates a figure with a barplot, were the counts is the bar height and values are the labels for the bars. Input can be a numpy array or a list of numpy array to create multiple plots.

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)

histogram[source]

histogram(values:Union[ndarray, List[ndarray]], bins:int=10, range:Tuple[int]=None, density:bool=False, remove_tools:bool=False, linked_axis=True, title='', x_label='', y_label='', orientation='horizontal', width:int=500, height:int=500)

Creates a histogram.

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)

heatmap[source]

heatmap(data:Union[DataFrame, List[DataFrame]], col_x:str, col_y:str, col_values:str, color_mapper:Optional[ColorMapper]=None, normalize:str='None', link_plots:bool=True, height:int=500, width:int=500)

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)

time_arc_plot[source]

time_arc_plot(start_dates:Series, end_dates:Iterable[datetime], width:int=500, height:int=300)

Creates a plot of arcs where each ark spans from a start date to an end date.

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"]))

table_from_dataframe[source]

table_from_dataframe(data:Union[DataFrame, List[DataFrame]], columns:List[str]=None, width:int=500, height:int=None, index_position:int=None, **kwargs)

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))

stacked_hist[source]

stacked_hist(data:Union[list, DataFrame], x_col:str, stack_col:str, x_label:str='', link_plots=True, width:int=500, height:int=500)

If normalize is True the biggest col is set to 1 and all other cols are scaled accordingly.

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))

categorical_2d_histogram[source]

categorical_2d_histogram(data:DataFrame, category_col:str, hist_col:str, bins=10, range=None, normalize=False, precision=2, color_mapper=None, hist_col_is_categorical=False, width=500, height=500)

Creates a 2d histogram with the y axis being a category and the x axis the value each category is histogramed over.

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[source]

categorical_2d_histogram_with_gui(data:DataFrame, category_cols=None, hist_cols=None, width=500, height=500)

Creates a categorical_2d_histogram for a dataframe, where each option (except width, height and color_mapper) of the categorical_2d_histogram can be set with gui elements. If the input is a list all dataframes need to have the same cols as the first dataframe in the list

categorical_2d_histogram_with_gui(test_data)
categorical_2d_histogram_with_gui([test_data, test_data])

scatter_plot_with_gui[source]

scatter_plot_with_gui(dataframe:DataFrame, x_cols:list=None, y_cols:list=None, color_cols:list=None, with_hist:bool=True, width=500, height=500)

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"])

plots_as_matrix[source]

plots_as_matrix(plots, ncols, nrows, width=500, height=500)

Takes a list of plots and puts them into a matrix

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)