Large Tables Report¶
-1 Illustration of full_table parameter.-
diff --git a/CHANGELOG.md b/CHANGELOG.md index f0fc013..a60a427 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,19 @@ # Changelog -## 1.0.0 (2023-09-02) +## 1.0.0 (2023-09-11) -- Updated to newer versions of optional dependencies. -- Created documentation at readthedocs. - Added new text elements `div()` and `span()`. Added new parameters to HTML elements - in particular `cl` and `attrs`. -- Deprecated `print_html()` function. New `print()` should be used instead. -- Deprecated `print_code()` function. New `print_source_code()` should be used instead. +- Replaced `print_html()` function with `print()`. +- Replaced `print_code()` function with `print_source_code()`. +- Replaced `plot_graph()` with `print_figure()`. +- Removed `plot_multi_graph`. - Replaced code-prettify with highlight.js for code blocks. - `print_h1`, ..., `print_h6` functions can now take a `Reference` object. - Added `--config-path` CLI option, changed how `pyreball-generate-config` command works and how the config paths are handled. +- Updated CLI arguments and config parameters for tables and figures. +- Updated to newer versions of 3rd party dependencies for example. +- Created documentation at readthedocs. ## 0.1.1 (2021-09-14) diff --git a/README.md b/README.md index 03aa08d..af0fb21 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ pb.print_table(df, caption="A data table.") fig, ax = plt.subplots() sns.lineplot(x="x", y="y", ax=ax, data=df) ax.set(xlabel="x", ylabel="y") -pb.plot_graph(fig, caption="The first plot.") +pb.print_figure(fig, caption="The first plot.") ``` In this particular example, we are using a few 3rd party packages, so let's install them too: diff --git a/docs/configuration.md b/docs/configuration.md index 4688561..8a65365 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -110,27 +110,27 @@ parameters. The following table shows the parameter alternatives between these t of given function. For example, instead of values `yes` and `no`, the functions usually use Boolean values `True` and `False`. -| `config.ini` key | CLI argument | Function argument | Description | -|---------------------------|-----------------------------|------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `toc` | `--toc ` | _N/A_ | Include table of contents. It is included only when there are any headings. Allowed values: `yes`, `no`. | -| `align-tables` | `--align-tables` | `align` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Horizontal alignment of tables. Allowed values: `left`, `center`, `right`. | -| `table-captions-position` | `--table-captions-position` | `caption_position` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Caption position. Allowed values: `top`, `bottom`. | -| `numbered-tables` | `--numbered-tables` | `numbered` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Whether to number tables. Allowed values: `yes`, `no`. | -| `tables-display-option` | `--tables-display-option` | `display_option` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | How to display table. This option is useful for long tables, which should not be displayed fully. Allowed values are: `full` (show the full table), `scrolling` (show the table in scrolling mode on y-axis), `paging` (show the table in paging mode). | -| `tables-paging-sizes` | `--tables-paging-sizes` | `paging_sizes` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | The paging sizes that can be selected. Ignored when `tables-display-option` is not `paging`. Allowed values are integers and string `all` (no matter the case of letters), written as a non-empty comma-separated list. | -| `tables-scroll-y-height` | `--tables-scroll-y-height` | `scroll_y_height` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Height of the tables when `tables-display-option` is set to `scrolling`. Any string compatible with CSS sizing can be used, e.g. `300px`, `20em`, etc. | -| `tables-scroll-x` | `--tables-scroll-x` | `scroll_x` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Whether to allow scrolling on the x-axis. If turned off, a wide table is allowed to overflow the main container. It is recommended to turn this on. Allowed values: `yes`, `no`. | -| `sortable-tables` | `--sortable-tables` | `sortable` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Whether to make columns in tables sortable. Allowed values: `yes`, `no`. | -| `tables-search-box` | `--tables-search-box` | `show_search_box` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Whether to show the search box for the tables. Allowed values: `yes`, `no`. | -| `tables-datatables-style` | `--tables-datatables-style` | `datatables_style` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Datatables class(es) that affect the tables styling. If multiple classes are provided, separate them either with commas or spaces. See [DataTables documentation](https://datatables.net/manual/styling/classes) with the possible values. | -| `align-plots` | `--align-plots` | `align` in [`plot_graph()`](../api/pyreball_html/#pyreball.html.plot_graph) | Horizontal alignment of plots. Allowed values: `left`, `center`, `right`. | -| `plot-captions-position` | `--plot-captions-position` | `caption_position` in [`plot_graph()`](../api/pyreball_html/#pyreball.html.plot_graph) | Caption position. Allowed values: `top`, `bottom`. | -| `numbered-plots` | `--numbered-plots` | `numbered` in [`plot_graph()`](../api/pyreball_html/#pyreball.html.plot_graph) | Whether to number plots. Allowed values: `yes`, `no`. | -| `matplotlib-format` | `--matplotlib-format` | `matplotlib_format` in [`plot_graph()`](../api/pyreball_html/#pyreball.html.plot_graph) | Format of matplotlib (and thus also seaborn) plots. Allowed values: `png`, `svg`. | -| `matplotlib-embedded` | `--matplotlib-embedded` | `embedded` in [`plot_graph()`](../api/pyreball_html/#pyreball.html.plot_graph) | Whether to embedded matplotlib (and thus also seaborn) plots directly into HTML. Only for svg format. Allowed values: `yes`, `no`. | -| `numbered-headings` | `--numbered-headings` | _N/A_ | Whether to number headings. Allowed values: `yes`, `no`. | -| `page-width` | `--page-width` | _N/A_ | Width of the page container in percentage. Allowed values: An integer in the range 40..100. | -| `keep-stdout` | `--keep-stdout` | _N/A_ | Whether to print the output to stdout too: `yes`, `no`. | +| `config.ini` key | CLI argument | Function argument | Description | +|----------------------------|------------------------------|------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `toc` | `--toc ` | _N/A_ | Include table of contents. It is included only when there are any headings. Allowed values: `yes`, `no`. | +| `align-tables` | `--align-tables` | `align` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Horizontal alignment of tables. Allowed values: `left`, `center`, `right`. | +| `table-captions-position` | `--table-captions-position` | `caption_position` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Caption position. Allowed values: `top`, `bottom`. | +| `numbered-tables` | `--numbered-tables` | `numbered` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Whether to number tables. Allowed values: `yes`, `no`. | +| `tables-display-option` | `--tables-display-option` | `display_option` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | How to display table. This option is useful for long tables, which should not be displayed fully. Allowed values are: `full` (show the full table), `scrolling` (show the table in scrolling mode on y-axis), `paging` (show the table in paging mode). | +| `tables-paging-sizes` | `--tables-paging-sizes` | `paging_sizes` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | The paging sizes that can be selected. Ignored when `tables-display-option` is not `paging`. Allowed values are integers and string `all` (no matter the case of letters), written as a non-empty comma-separated list. | +| `tables-scroll-y-height` | `--tables-scroll-y-height` | `scroll_y_height` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Height of the tables when `tables-display-option` is set to `scrolling`. Any string compatible with CSS sizing can be used, e.g. `300px`, `20em`, etc. | +| `tables-scroll-x` | `--tables-scroll-x` | `scroll_x` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Whether to allow scrolling on the x-axis. If turned off, a wide table is allowed to overflow the main container. It is recommended to turn this on. Allowed values: `yes`, `no`. | +| `sortable-tables` | `--sortable-tables` | `sortable` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Whether to make columns in tables sortable. Allowed values: `yes`, `no`. | +| `tables-search-box` | `--tables-search-box` | `show_search_box` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Whether to show the search box for the tables. Allowed values: `yes`, `no`. | +| `tables-datatables-style` | `--tables-datatables-style` | `datatables_style` in [`print_table()`](../api/pyreball_html/#pyreball.html.print_table) | Datatables class(es) that affect the tables styling. If multiple classes are provided, separate them either with commas or spaces. See [DataTables documentation](https://datatables.net/manual/styling/classes) with the possible values. | +| `align-figures` | `--align-figures` | `align` in [`print_figure()`](../api/pyreball_html/#pyreball.html.print_figure) | Horizontal alignment of figures. Allowed values: `left`, `center`, `right`. | +| `figure-captions-position` | `--figure-captions-position` | `caption_position` in [`print_figure()`](../api/pyreball_html/#pyreball.html.print_figure) | Caption position. Allowed values: `top`, `bottom`. | +| `numbered-figures` | `--numbered-figures` | `numbered` in [`print_figure()`](../api/pyreball_html/#pyreball.html.print_figure) | Whether to number figures. Allowed values: `yes`, `no`. | +| `matplotlib-format` | `--matplotlib-format` | `matplotlib_format` in [`print_figure()`](../api/pyreball_html/#pyreball.html.print_figure) | Format of matplotlib (and thus also seaborn) figures. Allowed values: `png`, `svg`. | +| `matplotlib-embedded` | `--matplotlib-embedded` | `embedded` in [`print_figure()`](../api/pyreball_html/#pyreball.html.print_figure) | Whether to embedded matplotlib (and thus also seaborn) figures directly into HTML. Only for svg format. Allowed values: `yes`, `no`. | +| `numbered-headings` | `--numbered-headings` | _N/A_ | Whether to number headings. Allowed values: `yes`, `no`. | +| `page-width` | `--page-width` | _N/A_ | Width of the page container in percentage. Allowed values: An integer in the range 40..100. | +| `keep-stdout` | `--keep-stdout` | _N/A_ | Whether to print the output to stdout too: `yes`, `no`. | The reason for having multiple options for setting these values is to allow the user to set some properties globally, while others locally as needed for particular scripts. diff --git a/docs/examples/example_init.py b/docs/examples/example_init.py index ee8a0c0..cbd83af 100644 --- a/docs/examples/example_init.py +++ b/docs/examples/example_init.py @@ -5,7 +5,7 @@ pb.print_div( "Pyreball has many features, among others:", pb.ulist( - "Creating plots.", + "Creating charts.", "Sortable and scrollable tables.", f'Basic text formatting such as {pb.em("emphasis")}.', f'Also {pb.link("hyperlinks", "https://www.python.org/")}.', diff --git a/docs/examples/example_init_deps.py b/docs/examples/example_init_deps.py index 83b3dce..612814d 100644 --- a/docs/examples/example_init_deps.py +++ b/docs/examples/example_init_deps.py @@ -3,14 +3,12 @@ import pyreball as pb import seaborn as sns -pb.set_title("Tables and Plots") +pb.set_title("Tables and Figures") -# Print a table df = pd.DataFrame({"x": [1, 2, 3], "y": [4, 6, 5]}) pb.print_table(df, caption="A data table.") -# Plot a graph fig, ax = plt.subplots() sns.lineplot(x="x", y="y", ax=ax, data=df) ax.set(xlabel="x", ylabel="y") -pb.plot_graph(fig, caption="A line plot.") +pb.print_figure(fig, caption="A line chart.") diff --git a/docs/examples/plotting_bokeh.py b/docs/examples/plotting_bokeh.py index d0ff05f..6b545ab 100644 --- a/docs/examples/plotting_bokeh.py +++ b/docs/examples/plotting_bokeh.py @@ -8,4 +8,4 @@ fig = figure(x_range=df["x"]) fig.vbar(x="x", top="y", width=0.9, source=ColumnDataSource(data=df)) fig.add_tools(HoverTool(tooltips=[("x", "@x"), ("y", "@y")])) -pb.plot_graph(fig, caption="Bokeh barchart.") +pb.print_figure(fig, caption="Bokeh barchart.") diff --git a/docs/examples/plotting_matplotlib_png.py b/docs/examples/plotting_matplotlib_png.py index d940dd0..34197f5 100644 --- a/docs/examples/plotting_matplotlib_png.py +++ b/docs/examples/plotting_matplotlib_png.py @@ -5,7 +5,7 @@ plt.bar([1, 2, 3], [4, 3, 6]) plt.xlabel("x") plt.ylabel("y") -pb.plot_graph( +pb.print_figure( fig, caption="Matplotlib barchart as png.", matplotlib_format="png", diff --git a/docs/examples/plotting_matplotlib_svg.py b/docs/examples/plotting_matplotlib_svg.py index b6d8f4d..9dd5a68 100644 --- a/docs/examples/plotting_matplotlib_svg.py +++ b/docs/examples/plotting_matplotlib_svg.py @@ -5,7 +5,7 @@ plt.bar([1, 2, 3], [4, 3, 6]) plt.xlabel("x") plt.ylabel("y") -pb.plot_graph( +pb.print_figure( fig, caption="Matplotlib barchart as svg.", matplotlib_format="svg", diff --git a/docs/examples/plotting_plotly.py b/docs/examples/plotting_plotly.py index c560c71..78f19e6 100644 --- a/docs/examples/plotting_plotly.py +++ b/docs/examples/plotting_plotly.py @@ -5,4 +5,4 @@ df = pd.DataFrame({"x": [1, 2, 3], "y": [4, 3, 6]}) fig = px.bar(df, x="x", y="y") -pb.plot_graph(fig, caption="Plotly graph.") +pb.print_figure(fig, caption="Plotly chart.") diff --git a/docs/examples/plotting_seaborn.py b/docs/examples/plotting_seaborn.py index cf6c323..2b3496a 100644 --- a/docs/examples/plotting_seaborn.py +++ b/docs/examples/plotting_seaborn.py @@ -8,7 +8,7 @@ fig, ax = plt.subplots() sns.barplot(x="x", y="y", data=df, ax=ax, color=sns.xkcd_rgb["windows blue"]) ax.set(xlabel="x", ylabel="y") -pb.plot_graph( +pb.print_figure( fig, caption="Seaborn barchart as png.", matplotlib_format="png", diff --git a/docs/examples/plotting_vega_altair.py b/docs/examples/plotting_vega_altair.py index 481cd83..9a24927 100644 --- a/docs/examples/plotting_vega_altair.py +++ b/docs/examples/plotting_vega_altair.py @@ -23,4 +23,4 @@ height=400, ) ) -pb.plot_graph(fig, caption="Vega-Altair barchart.") +pb.print_figure(fig, caption="Vega-Altair barchart.") diff --git a/docs/examples/references.py b/docs/examples/references.py index 168b87e..cd9dbf9 100644 --- a/docs/examples/references.py +++ b/docs/examples/references.py @@ -5,7 +5,7 @@ import pyreball as pb import seaborn as sns -pb.set_title("References to Plots and Tables") +pb.set_title("References to Figures and Tables") ref_ch_1 = pb.Reference() @@ -47,7 +47,7 @@ fig, ax = plt.subplots() sns.scatterplot(x="x", y="y", ax=ax, data=df) ax.set(xlabel="x", ylabel="y") -pb.plot_graph(fig, caption="A plot with a reference.", reference=img_reference) +pb.print_figure(fig, caption="A figure with a reference.", reference=img_reference) pb.print_div( f"Note that you can use the references in your text multiple times, " diff --git a/docs/examples/references_simple.py b/docs/examples/references_simple.py index 07e8598..204a90a 100644 --- a/docs/examples/references_simple.py +++ b/docs/examples/references_simple.py @@ -4,6 +4,6 @@ ref = pb.Reference("My Table") pb.print(f"It is possible to create a link {ref} before the target...") -pb.print_table(pd.DataFrame({'a': [1, 2], 'b': [3, 4]}), reference=ref) +pb.print_table(pd.DataFrame({"a": [1, 2], "b": [3, 4]}), reference=ref) pb.print(f"and also link {ref} after the target.") pb.print(f"It is also possible to create {ref('link with custom text')}.") diff --git a/docs/examples/text_utils_formatting.py b/docs/examples/text_utils_formatting.py index 20ab2db..3bf61ff 100644 --- a/docs/examples/text_utils_formatting.py +++ b/docs/examples/text_utils_formatting.py @@ -1,6 +1,5 @@ import pyreball as pb pb.print( - f"This sentence contains both {pb.bold('bold')} " - f"and {pb.em('emphasized')} text." + f"This sentence contains both {pb.bold('bold')} " f"and {pb.em('emphasized')} text." ) diff --git a/docs/index.md b/docs/index.md index 7975ca4..1326434 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,7 +4,7 @@ Pyreball is a Python reporting tool that generates HTML reports from Python scri Main features: -- Plots in [Vega-Altair](https://altair-viz.github.io/index.html), [Plotly](https://plotly.com/), [Bokeh](https://bokeh.org/), and [Matplotlib](https://matplotlib.org/) (and thus also [Seaborn](https://seaborn.pydata.org/) etc.). +- Charts in [Vega-Altair](https://altair-viz.github.io/index.html), [Plotly](https://plotly.com/), [Bokeh](https://bokeh.org/), and [Matplotlib](https://matplotlib.org/) (and thus also [Seaborn](https://seaborn.pydata.org/) etc.). - Interactive tables based on [DataTables](https://datatables.net/) library and created from [pandas DataFrame](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.html). - Basic text formatting such as headings, emphasis, and lists. - Hyperlinks, references and table of contents. @@ -39,13 +39,13 @@ pyreball report.py -## Adding Tables and Plots +## Adding Tables and Figures The core functionality of `pyreball` does not require any 3rd party dependencies. However, it is possible to generate other types of elements with the help of libraries such as [pandas](https://pandas.pydata.org/) or [seaborn](https://seaborn.pydata.org/). -Let's create another python script called `report_plot.py`: +Let's create another python script called `report_chart.py`: {{ inline_source("docs/examples/example_init_deps.py") }} @@ -53,9 +53,9 @@ Install `pandas` and `seaborn`, then run `pyreball`: ``` pip install pandas seaborn -pyreball report_plot.py +pyreball report_chart.py ``` -`report_plot.html` should look like this: +`report_chart.html` should look like this: diff --git a/docs/plotting.md b/docs/plotting.md index 11b8812..f8aa45a 100644 --- a/docs/plotting.md +++ b/docs/plotting.md @@ -4,23 +4,23 @@ Pyreball currently supports plotting figures created by [Matplotlib](https://matplotlib.org/), [Seaborn](https://seaborn.pydata.org/), [Vega-Altair](https://altair-viz.github.io/index.html), [Plotly](https://plotly.com/), and [Bokeh](https://bokeh.org/). -There is a single function [`plot_graph()`](../api/pyreball_html/#pyreball.html.plot_graph) for all these libraries. +There is a single function [`print_figure()`](../api/pyreball_html/#pyreball.html.print_figure) for all these libraries. Similarly to [`print_table()`](../api/pyreball_html/#pyreball.html.print_table), it uses parameters `caption`, `align`, `caption_position` and `numbered` with the same meaning. -In contrast to table captions, the default position of plot captions is `bottom`. +In contrast to table captions, the default position of figure captions is `bottom`. ## Matplotlib When plotting with Matplotlib, it is necessary to create a figure object and pass it -to [`plot_graph()`](../api/pyreball_html/#pyreball.html.plot_graph). +to [`print_figure()`](../api/pyreball_html/#pyreball.html.print_figure). -In case of Matplotlib, a user can select the format of the plot via `matplotlib_format` parameter: either `"png"` +In case of Matplotlib, a user can select the format of the figure via `matplotlib_format` parameter: either `"png"` or `"svg"`. -In case of `"svg"`, it is also possible to choose whether the plot should be embedded into the HTML file or saved into a -separate file and referenced in the HTML file by setting `embedded` accordingly. -Plots in `"png"` format cannot be embedded into the HTML file. +In case of `"svg"`, it is also possible to choose whether the figure should be embedded into the HTML file +or saved into a separate file and referenced in the HTML file by setting `embedded` accordingly. +Figures in `"png"` format cannot be embedded into the HTML file. -When the plot is stored into a file, the file is saved in a directory with name equal to the filename stem of the HTML +When the figure is stored into a file, the file is saved in a directory with name equal to the filename stem of the HTML file. For example, for HTML file `report.html`, the image file will be stored in directory `report`. The following code shows an example of a bar chart created with Matplotlib and stored in a `"png"` format. @@ -29,7 +29,7 @@ The following code shows an example of a bar chart created with Matplotlib and s -The next example shows the same plot, but embedded directly into the HTML document in `"svg"` format. +The next example shows the same chart, but embedded directly into the HTML document in `"svg"` format. {{ inline_source("docs/examples/plotting_matplotlib_svg.py") }} @@ -58,7 +58,7 @@ e.g. `altair.ConcatChart`, `altair.HConcatChart`. ## Plotly -Pyreball supports interactive plots created by Plotly, too. +Pyreball supports interactive charts created by Plotly, too. {{ inline_source("docs/examples/plotting_plotly.py") }} @@ -66,7 +66,7 @@ Pyreball supports interactive plots created by Plotly, too. ## Bokeh -Another library for plotting interactive plots supported by Pyreball is Bokeh. +Another library for plotting interactive charts supported by Pyreball is Bokeh. {{ inline_source("docs/examples/plotting_bokeh.py") }} diff --git a/docs/references.md b/docs/references.md index 3d06f4d..bf74af4 100644 --- a/docs/references.md +++ b/docs/references.md @@ -7,7 +7,7 @@ class. Specifically, one can create a reference object by calling `pb.Reference()`. This object can be then passed to a function that creates a table ([`print_table()`](../api/pyreball_html/#pyreball.html.print_table)), -a plot ([`plot_graph()`](../api/pyreball_html/#pyreball.html.plot_graph)), or +a figure ([`print_figure()`](../api/pyreball_html/#pyreball.html.print_figure)), or a heading ([`print_h1()`](../api/pyreball_html/#pyreball.html.print_h1), ..., [`print_h6()`](../api/pyreball_html/#pyreball.html.print_h6)). Each such function then creates a target for the link. @@ -31,8 +31,8 @@ a parameter that is used to override the default link text. When default link text is not provided through the constructor, Pyreball uses table numbers as texts for links pointing -to tables. The same is applied for links pointing to plots. In case of headings, the default link text would be the text -of the heading itself. +to tables. The same is applied for links pointing to figures. +In case of headings, the default link text would be the text of the heading itself. The artificial example below demonstrates some of these features. diff --git a/examples/large_table_report.html b/examples/large_table_report.html deleted file mode 100644 index db07175..0000000 --- a/examples/large_table_report.html +++ /dev/null @@ -1,189 +0,0 @@ - - -
-full_table
parameter.¶x | -y | -
---|---|
1 | -5.155267 | -
2 | -4.676778 | -
3 | -5.740878 | -
4 | -3.817809 | -
5 | -6.512470 | -
6 | -3.109550 | -
7 | -5.681870 | -
8 | -4.669219 | -
9 | -5.234759 | -
10 | -3.561548 | -
x | -y | -
---|---|
1 | -5.155267 | -
2 | -4.676778 | -
3 | -5.740878 | -
4 | -3.817809 | -
5 | -6.512470 | -
6 | -3.109550 | -
7 | -5.681870 | -
8 | -4.669219 | -
9 | -5.234759 | -
10 | -3.561548 | -