From 48a3a9aa7cff06a3525e9b498b521b7747e3dcf7 Mon Sep 17 00:00:00 2001 From: Michael Chow Date: Mon, 8 Jul 2024 14:30:26 -0400 Subject: [PATCH 01/12] docs: draft blog for scientific publishing --- .../index.qmd | 158 ++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 docs/blog/tables-for-scientific-publishing/index.qmd diff --git a/docs/blog/tables-for-scientific-publishing/index.qmd b/docs/blog/tables-for-scientific-publishing/index.qmd new file mode 100644 index 000000000..0e53764bf --- /dev/null +++ b/docs/blog/tables-for-scientific-publishing/index.qmd @@ -0,0 +1,158 @@ +--- +title: Great Tables for Scientific Publishing +jupyter: python3 +format: + html: + code-fold: true + code-summary: "Show the Code" +--- + +Great Tables version `0.10.0` released today, with a host of new features to support tables for scientific publishing. + +In this post, we'll review the big pieces that scientific tables need: + +* **Unit notation**: rendering units and chemical formulas (e.g. °C or CH4). +* **Scientific notation**: formatting for very large and small numbers (e.g. 3.50 × 10−11) +* **Nanoplots**: compact visualizations for revealing trends. + +We've added **6 new datasets**, to help quickly show off scientific publishing! We'll use our `reactions` and `gibraltar` data to highlight examples from atmospheric chemistry and meterology, respectively. + +:::{.callout-tip} +Rich will be speaking on this at scipy. + +TODO: add details (and link to session?) +::: + + +## Unit and scientific notation + +{SHORT BACKGROUND ON DATA}. + +Reporting this requires representing three pieces: + +* units like `cm^3` +* chemical compounds like CH4 +* very small numbers in scientific format. + +This is shown in the table below: + +```{python} +from great_tables import GT, md, system_fonts +from great_tables.data import reactions +import polars as pl +import polars.selectors as ps +reactions_mini = ( + pl.from_pandas(reactions) + .filter(pl.col("cmpd_type") == "mercaptan") + .select([ + "cmpd_name", + "cmpd_formula", + ps.ends_with("k298") + ]) + .with_columns( + cmpd_formula=pl.concat_str( + "%" + pl.col("cmpd_formula") + "%" + ) + ) +) +( + GT(reactions_mini, rowname_col="cmpd_name") + .tab_header(title="Gas-phase reactions \ + of selected mercaptan compounds") + .tab_spanner( + columns=ps.ends_with("k298"), + label = "Reaction Rate Constant (298 K),
{{cm^3 molecules^–1 s^–1}}" + ) + .fmt_units(columns="cmpd_formula") + .fmt_scientific(columns=ps.ends_with("k298")) + .sub_missing() + .cols_hide(columns="O3_k298") + .cols_label( + cmpd_formula="", + OH_k298="OH", + NO3_k298="{{%NO3%}}", + Cl_k298="Cl", + ) + .opt_stylize(style=1, color="blue") + .opt_horizontal_padding(scale=3) + .tab_options( + table_font_names=system_fonts("humanist"), + ) +) +``` + +Note these pieces: + +* The `label=` argument to functions like `tab_spanner()` supports a curly braces for special units syntax. `"{{cm^3 molecules^–1 s^–1}}"` becomes cm3 TODO finish +* The `fmt_units()` converts values that are unit syntax directly. For example the cell "%CH4S%"` becomes CH4S. + + +## Nanoplots + + + + +```{python} +from great_tables import GT, md, nanoplot_options +from great_tables.data import gibraltar +import polars as pl +import polars.selectors as ps +from datetime import datetime +def to_seconds(timestr): + seconds= 0 + for part in timestr.split(':'): + seconds= seconds*60 + int(part, 10) + return seconds +nano_opts = nanoplot_options( + data_point_radius=4, + data_point_stroke_width=4, + data_point_stroke_color="black", + data_point_fill_color="white", + data_line_stroke_width=4, + data_line_stroke_color="gray", + show_data_line=True, + show_data_points=True, + show_data_area=False, + ) +gibraltar_mini = ( + pl.from_pandas(gibraltar) + .filter(pl.col("date") <= "2023-05-10") + #.with_columns(time=pl.concat_str(pl.col("time") + ":00")) + #.with_columns( + # pl.col("time").map_elements( + # to_seconds, + # return_dtype=int + # ) + #) + .with_columns(pl.col("humidity") * 100) + .select(["date", "temp", "humidity"]) + .group_by("date") + .agg( + pl.col("temp"), + pl.col("humidity"), + ) + .sort("date") +) +( + GT(gibraltar_mini) + .tab_header( + title="Meteorological Summary of Gibraltar Station", + subtitle="Data taken from May 1-10, 2023." + ) + .fmt_nanoplot( + columns="temp", autoscale=True, options=nano_opts + ) + .fmt_nanoplot( + columns="humidity", autoscale=True, options=nano_opts + ) + .fmt_date( + columns="date", + date_style="wd_m_day_year" + ) + .cols_label( + date="Date", + temp="Temperature, {{:degree:C}}", + humidity="Humidity, % (RH)", + ) +) +``` From 4699b29b656d484ca3cb17ac272e37ab53fc4b70 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Mon, 8 Jul 2024 14:42:24 -0400 Subject: [PATCH 02/12] Tweak intro; add SciPy talk info --- .../blog/tables-for-scientific-publishing/index.qmd | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/blog/tables-for-scientific-publishing/index.qmd b/docs/blog/tables-for-scientific-publishing/index.qmd index 0e53764bf..da9fde5ec 100644 --- a/docs/blog/tables-for-scientific-publishing/index.qmd +++ b/docs/blog/tables-for-scientific-publishing/index.qmd @@ -7,23 +7,22 @@ format: code-summary: "Show the Code" --- -Great Tables version `0.10.0` released today, with a host of new features to support tables for scientific publishing. +Great Tables version `0.10.0` has be released today and it contains a host of new features to support tables meant for scientific publishing. In this post, we'll review the big pieces that scientific tables need: -* **Unit notation**: rendering units and chemical formulas (e.g. °C or CH4). -* **Scientific notation**: formatting for very large and small numbers (e.g. 3.50 × 10−11) +* **Unit notation**: rendering units and chemical formulas (e.g., °C or C6H6). +* **Scientific notation**: formatting for very large and small numbers (e.g., 3.50 × 10−11) * **Nanoplots**: compact visualizations for revealing trends. -We've added **6 new datasets**, to help quickly show off scientific publishing! We'll use our `reactions` and `gibraltar` data to highlight examples from atmospheric chemistry and meterology, respectively. +We've added **6 new datasets**, to help quickly show off scientific publishing! We'll use the new `reactions` and `gibraltar` datasets to create examples in the fields of Atmospheric Chemistry and Meterology, respectively. :::{.callout-tip} -Rich will be speaking on this at scipy. +Rich will be speaking on this at SciPy! -TODO: add details (and link to session?) +If you're at SciPy 2024 in Tacoma, WA, Rich's talk is scheduled for July 11 (16:30–17:00 PT). The talk is called *Great Tables for Everyone* and it's sure to be both exciting and educational. If you're not attending that's okay, the talk is available [in GitHub](https://github.com/rich-iannone/presentations/tree/main/2024-07-11-SciPy-talk-GT). ::: - ## Unit and scientific notation {SHORT BACKGROUND ON DATA}. From 53dd27fa0d2640ae4c86a8cbf6722957fb466c64 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Mon, 8 Jul 2024 15:11:28 -0400 Subject: [PATCH 03/12] Add intro to 'Unit and scientific notation' section --- .../blog/tables-for-scientific-publishing/index.qmd | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/blog/tables-for-scientific-publishing/index.qmd b/docs/blog/tables-for-scientific-publishing/index.qmd index da9fde5ec..2fb73c756 100644 --- a/docs/blog/tables-for-scientific-publishing/index.qmd +++ b/docs/blog/tables-for-scientific-publishing/index.qmd @@ -25,21 +25,22 @@ If you're at SciPy 2024 in Tacoma, WA, Rich's talk is scheduled for July 11 (16: ## Unit and scientific notation -{SHORT BACKGROUND ON DATA}. +We added the `reactions` dataset to serve as the basis for examples in the discipline of Atmospheric Chemistry. The dataset contains reaction rate constants for gas-phase reactions of 1,683 organic compounds. Each of these compounds can potentially undergo reaction with hydroxyl radicals (OH), nitrate radicals (NO3), or chlorine atoms (Cl). These reaction rate constants are typically very small values in units of cm3 molecules-1 s-1. In the upcoming example, we'll pare down this massive dataset to only 11 rows representing the class of organic compounds known as mercaptans. -Reporting this requires representing three pieces: +To make this table work well in a scientific reporting context, we need three pieces: -* units like `cm^3` -* chemical compounds like CH4 -* very small numbers in scientific format. +* way to represent units, like cm3 +* method for typesetting chemical formulae, as in CH4 +* formatting for very small numbers in scientific notation. -This is shown in the table below: +**Great Tables** provides the necessary functionality for all three requirements. Here is a summary table that tabulates rate constants for mercaptan compounds undergoing reaction with OH, O3, and Cl: ```{python} from great_tables import GT, md, system_fonts from great_tables.data import reactions import polars as pl import polars.selectors as ps + reactions_mini = ( pl.from_pandas(reactions) .filter(pl.col("cmpd_type") == "mercaptan") From d18720d83d53507cb263eb0b389dd4e0da30ea65 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Mon, 8 Jul 2024 15:29:01 -0400 Subject: [PATCH 04/12] Add text to the 'Unit and scientific notation' section --- .../tables-for-scientific-publishing/index.qmd | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/blog/tables-for-scientific-publishing/index.qmd b/docs/blog/tables-for-scientific-publishing/index.qmd index 2fb73c756..cabd0f7bc 100644 --- a/docs/blog/tables-for-scientific-publishing/index.qmd +++ b/docs/blog/tables-for-scientific-publishing/index.qmd @@ -55,13 +55,13 @@ reactions_mini = ( ) ) ) + ( GT(reactions_mini, rowname_col="cmpd_name") - .tab_header(title="Gas-phase reactions \ - of selected mercaptan compounds") + .tab_header(title="Gas-phase reactions of selected mercaptan compounds") .tab_spanner( columns=ps.ends_with("k298"), - label = "Reaction Rate Constant (298 K),
{{cm^3 molecules^–1 s^–1}}" + label="Reaction Rate Constant (298 K),
{{cm^3 molecules^–1 s^–1}}" ) .fmt_units(columns="cmpd_formula") .fmt_scientific(columns=ps.ends_with("k298")) @@ -81,11 +81,13 @@ reactions_mini = ( ) ``` -Note these pieces: +This is a nice-looking table! And note these pieces: -* The `label=` argument to functions like `tab_spanner()` supports a curly braces for special units syntax. `"{{cm^3 molecules^–1 s^–1}}"` becomes cm3 TODO finish -* The `fmt_units()` converts values that are unit syntax directly. For example the cell "%CH4S%"` becomes CH4S. +* The `label=` argument to functions like `.tab_spanner()` supports the use of curly braces (`{{`/`}}`) for the specialized units notation. So using `"{{cm^3 molecules^–1 s^–1}}"` in the input will become cm3 molecules–1 s–1 in the output +* The `.fmt_units()` method converts values that are already in units notation in the table body. For example, a cell with text `"%CH4S%"` becomes CH4S (the surrounding `%` indicates that the text should be interpreted as chemistry notation). +* The `.fmt_scientific()` method formats values (in this case, very small values) to scientific notation (e.g., 3.50 × 10–11). Not doing so would make the table look very strange to a researcher that is familar with this sort of data. +The combination of units notation (and chemistry notation, which is a part of that) really makes the presentation of this table complete and understandable to a practioner of the field. Great Tables supports the use of units notation in spanner labels (with `.tab_spanner()`) and also in column labels (with `.cols_labels()`). The column label 'NO3' was created with the latter method by supplying the text `"{{%NO3%}}"` as the column label for the `NO3_k298` column. ## Nanoplots From d126fef681097aa2b79fc9a1d5a0abe5c21930c4 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Mon, 8 Jul 2024 15:30:48 -0400 Subject: [PATCH 05/12] Make small copy editing tweaks --- docs/blog/tables-for-scientific-publishing/index.qmd | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/blog/tables-for-scientific-publishing/index.qmd b/docs/blog/tables-for-scientific-publishing/index.qmd index cabd0f7bc..a10a31807 100644 --- a/docs/blog/tables-for-scientific-publishing/index.qmd +++ b/docs/blog/tables-for-scientific-publishing/index.qmd @@ -7,7 +7,7 @@ format: code-summary: "Show the Code" --- -Great Tables version `0.10.0` has be released today and it contains a host of new features to support tables meant for scientific publishing. +**Great Tables** version `0.10.0` has be released today and it contains a host of new features to support tables meant for scientific publishing. In this post, we'll review the big pieces that scientific tables need: @@ -15,17 +15,17 @@ In this post, we'll review the big pieces that scientific tables need: * **Scientific notation**: formatting for very large and small numbers (e.g., 3.50 × 10−11) * **Nanoplots**: compact visualizations for revealing trends. -We've added **6 new datasets**, to help quickly show off scientific publishing! We'll use the new `reactions` and `gibraltar` datasets to create examples in the fields of Atmospheric Chemistry and Meterology, respectively. +We've added **six new datasets**, to help quickly show off scientific publishing! We'll use the new `reactions` and `gibraltar` datasets to create examples in the fields of Atmospheric Chemistry and Meterology, respectively. :::{.callout-tip} Rich will be speaking on this at SciPy! -If you're at SciPy 2024 in Tacoma, WA, Rich's talk is scheduled for July 11 (16:30–17:00 PT). The talk is called *Great Tables for Everyone* and it's sure to be both exciting and educational. If you're not attending that's okay, the talk is available [in GitHub](https://github.com/rich-iannone/presentations/tree/main/2024-07-11-SciPy-talk-GT). +If you're at SciPy 2024 in Tacoma, WA, Rich's talk is scheduled for July 11, 2024 (16:30–17:00 PT). The talk is called *Great Tables for Everyone* and it's sure to be both exciting and educational. If you're not attending that's okay, the talk is available [in GitHub](https://github.com/rich-iannone/presentations/tree/main/2024-07-11-SciPy-talk-GT). ::: ## Unit and scientific notation -We added the `reactions` dataset to serve as the basis for examples in the discipline of Atmospheric Chemistry. The dataset contains reaction rate constants for gas-phase reactions of 1,683 organic compounds. Each of these compounds can potentially undergo reaction with hydroxyl radicals (OH), nitrate radicals (NO3), or chlorine atoms (Cl). These reaction rate constants are typically very small values in units of cm3 molecules-1 s-1. In the upcoming example, we'll pare down this massive dataset to only 11 rows representing the class of organic compounds known as mercaptans. +We added the `reactions` dataset to serve as the basis for examples in the discipline of Atmospheric Chemistry. The dataset contains reaction rate constants for gas-phase reactions of 1,683 organic compounds. Each of these compounds can potentially undergo reaction with hydroxyl radicals (OH), nitrate radicals (NO3), or chlorine atoms (Cl). These reaction rate constants are typically very small values in units of cm3 molecules–1 s–1. In the upcoming example, we'll pare down this massive dataset to only 11 rows representing the class of organic compounds known as mercaptans. To make this table work well in a scientific reporting context, we need three pieces: @@ -87,7 +87,7 @@ This is a nice-looking table! And note these pieces: * The `.fmt_units()` method converts values that are already in units notation in the table body. For example, a cell with text `"%CH4S%"` becomes CH4S (the surrounding `%` indicates that the text should be interpreted as chemistry notation). * The `.fmt_scientific()` method formats values (in this case, very small values) to scientific notation (e.g., 3.50 × 10–11). Not doing so would make the table look very strange to a researcher that is familar with this sort of data. -The combination of units notation (and chemistry notation, which is a part of that) really makes the presentation of this table complete and understandable to a practioner of the field. Great Tables supports the use of units notation in spanner labels (with `.tab_spanner()`) and also in column labels (with `.cols_labels()`). The column label 'NO3' was created with the latter method by supplying the text `"{{%NO3%}}"` as the column label for the `NO3_k298` column. +The combination of units notation (and chemistry notation, which is a part of that) really makes the presentation of this table complete and understandable to a practioner of the field. **Great Tables** supports the use of units notation in spanner labels (with `.tab_spanner()`) and also in column labels (with `.cols_labels()`). The column label 'NO3' was created with the latter method by supplying the text `"{{%NO3%}}"` as the column label for the `NO3_k298` column. ## Nanoplots From c962e4919059a7ef49277833a1b3b1d2eeb5b658 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Mon, 8 Jul 2024 15:36:00 -0400 Subject: [PATCH 06/12] Refine GT table code --- .../index.qmd | 30 +++++++------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/docs/blog/tables-for-scientific-publishing/index.qmd b/docs/blog/tables-for-scientific-publishing/index.qmd index a10a31807..7d67d0186 100644 --- a/docs/blog/tables-for-scientific-publishing/index.qmd +++ b/docs/blog/tables-for-scientific-publishing/index.qmd @@ -36,7 +36,7 @@ To make this table work well in a scientific reporting context, we need three pi **Great Tables** provides the necessary functionality for all three requirements. Here is a summary table that tabulates rate constants for mercaptan compounds undergoing reaction with OH, O3, and Cl: ```{python} -from great_tables import GT, md, system_fonts +from great_tables import GT from great_tables.data import reactions import polars as pl import polars.selectors as ps @@ -75,9 +75,7 @@ reactions_mini = ( ) .opt_stylize(style=1, color="blue") .opt_horizontal_padding(scale=3) - .tab_options( - table_font_names=system_fonts("humanist"), - ) + .opt_table_font(stack="humanist") ) ``` @@ -93,18 +91,18 @@ The combination of units notation (and chemistry notation, which is a part of th - ```{python} -from great_tables import GT, md, nanoplot_options +from great_tables import GT, nanoplot_options from great_tables.data import gibraltar import polars as pl import polars.selectors as ps -from datetime import datetime + def to_seconds(timestr): - seconds= 0 + seconds = 0 for part in timestr.split(':'): - seconds= seconds*60 + int(part, 10) + seconds = seconds*60 + int(part, 10) return seconds + nano_opts = nanoplot_options( data_point_radius=4, data_point_stroke_width=4, @@ -116,25 +114,17 @@ nano_opts = nanoplot_options( show_data_points=True, show_data_area=False, ) + gibraltar_mini = ( pl.from_pandas(gibraltar) .filter(pl.col("date") <= "2023-05-10") - #.with_columns(time=pl.concat_str(pl.col("time") + ":00")) - #.with_columns( - # pl.col("time").map_elements( - # to_seconds, - # return_dtype=int - # ) - #) .with_columns(pl.col("humidity") * 100) .select(["date", "temp", "humidity"]) .group_by("date") - .agg( - pl.col("temp"), - pl.col("humidity"), - ) + .agg(pl.col("temp"), pl.col("humidity")) .sort("date") ) + ( GT(gibraltar_mini) .tab_header( From 6d25275acd9eb630d5faf9cf94ed8d0c762f9c78 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Mon, 8 Jul 2024 16:11:26 -0400 Subject: [PATCH 07/12] Add text around nanoplots example --- .../tables-for-scientific-publishing/index.qmd | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/blog/tables-for-scientific-publishing/index.qmd b/docs/blog/tables-for-scientific-publishing/index.qmd index 7d67d0186..3a7980fc4 100644 --- a/docs/blog/tables-for-scientific-publishing/index.qmd +++ b/docs/blog/tables-for-scientific-publishing/index.qmd @@ -89,19 +89,14 @@ The combination of units notation (and chemistry notation, which is a part of th ## Nanoplots +We added the nanoplots feature to **Great Tables** in v0.4.0 (check out the [intro blog post](https://posit-dev.github.io/great-tables/blog/introduction-0.4.0/) for a quick explainer) so that tables can contain small, info-packed plots that fit reasonably well into a table context. They are interactive in that hovering over the data points provides additional plot information. This approach brings together the advantages of plots (elucidation of trends in data) and tables (access to numerical values representing the data points) in a single summary visualization. Version `0.10.0` of **Great Tables** adds the `gibraltar` dataset, which provides meteorological data (temeperature, humidity, wind speed, etc.) for the entire month of May 2024 at Gibraltar Airport Station. +Nanoplots, as mentioned, are great for condensing a lot of information into a small area. Our example here with the `gibraltar` dataset takes all of the temperature and humidity data for the first 10 days of May 2023 and displays them in easy-to-explore nanoplots across two columns: ```{python} from great_tables import GT, nanoplot_options from great_tables.data import gibraltar import polars as pl -import polars.selectors as ps - -def to_seconds(timestr): - seconds = 0 - for part in timestr.split(':'): - seconds = seconds*60 + int(part, 10) - return seconds nano_opts = nanoplot_options( data_point_radius=4, @@ -148,3 +143,9 @@ gibraltar_mini = ( ) ) ``` + +The **Polars** library helps us to easily aggregate the temperature and humidity data in the `temp` and `humidity` columns by `date`. Once we have the data aggregated in the form of list columns, the `.fmt_nanoplot()` method is then called on the two aforementioned columns to create the two columns of nanoplots. We have a lot of customization options for nanoplots available in the `nanoplot_options()` function and its use here allows us to craft visuals that fit within the data-display conventions of specific disciplines. In this case, we wanted a monochrome look and so we applied the result of the `nanoplot_options()` call to the `options=` arg of `.fmt_nanoplot()` (which is used twice here). + +Units notation is also used here! It could potentially be difficult to format even simple things like the units of temperature. In this case we wanted to express the units of °C for the `temperature` column. Units notation has a collection of symbols available, including `":degree:"` (colons encapsulate the collection of symbol keywords), for insertion within units notation text. + + From eae2c152fb3160ae73c0785bfb819dfcd38f3895 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Mon, 8 Jul 2024 16:14:18 -0400 Subject: [PATCH 08/12] Add author and date metadata --- docs/blog/tables-for-scientific-publishing/index.qmd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/blog/tables-for-scientific-publishing/index.qmd b/docs/blog/tables-for-scientific-publishing/index.qmd index 3a7980fc4..0a464bf1a 100644 --- a/docs/blog/tables-for-scientific-publishing/index.qmd +++ b/docs/blog/tables-for-scientific-publishing/index.qmd @@ -1,5 +1,8 @@ --- title: Great Tables for Scientific Publishing +html-table-processing: none +author: Rich Iannone +date: 2024-07-08 jupyter: python3 format: html: From 4b29f674d1cd14bd9ab70c40311be0f5120a9397 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Mon, 8 Jul 2024 16:19:24 -0400 Subject: [PATCH 09/12] Add concluding section --- docs/blog/tables-for-scientific-publishing/index.qmd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/blog/tables-for-scientific-publishing/index.qmd b/docs/blog/tables-for-scientific-publishing/index.qmd index 0a464bf1a..1a3c48aee 100644 --- a/docs/blog/tables-for-scientific-publishing/index.qmd +++ b/docs/blog/tables-for-scientific-publishing/index.qmd @@ -151,4 +151,8 @@ The **Polars** library helps us to easily aggregate the temperature and humidity Units notation is also used here! It could potentially be difficult to format even simple things like the units of temperature. In this case we wanted to express the units of °C for the `temperature` column. Units notation has a collection of symbols available, including `":degree:"` (colons encapsulate the collection of symbol keywords), for insertion within units notation text. +## Hope all your (science-y) tables are great! +We did scientific work pretty heavily in the past and so we understand that great tables in the realm of science publication is something that could and should be possible. We'll keep doing more to make this even better in upcoming releases. + +Hope to see you at SciPy 2024! From b3c4186b13b547906e36e996226852a9d965a082 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Mon, 8 Jul 2024 17:06:55 -0400 Subject: [PATCH 10/12] Modify text after nanoplots table --- docs/blog/tables-for-scientific-publishing/index.qmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/blog/tables-for-scientific-publishing/index.qmd b/docs/blog/tables-for-scientific-publishing/index.qmd index 1a3c48aee..143ebf34a 100644 --- a/docs/blog/tables-for-scientific-publishing/index.qmd +++ b/docs/blog/tables-for-scientific-publishing/index.qmd @@ -147,9 +147,9 @@ gibraltar_mini = ( ) ``` -The **Polars** library helps us to easily aggregate the temperature and humidity data in the `temp` and `humidity` columns by `date`. Once we have the data aggregated in the form of list columns, the `.fmt_nanoplot()` method is then called on the two aforementioned columns to create the two columns of nanoplots. We have a lot of customization options for nanoplots available in the `nanoplot_options()` function and its use here allows us to craft visuals that fit within the data-display conventions of specific disciplines. In this case, we wanted a monochrome look and so we applied the result of the `nanoplot_options()` call to the `options=` arg of `.fmt_nanoplot()` (which is used twice here). +Once we have the data aggregated in the form of list columns, the `.fmt_nanoplot()` method shows us the trends of temperature and relative humidity values throughout the day (from `00:00` to `24:00`). One interesting observation that can be made from the table is that on May 9, 2023 there was a late-day temperature increase that coincided with a corresponding decrease in relative humidity. Making such an observation without nanoplots would be quite a bit more difficult and would require some serious determination, necessitating a careful scanning of numbers across a row cells. -Units notation is also used here! It could potentially be difficult to format even simple things like the units of temperature. In this case we wanted to express the units of °C for the `temperature` column. Units notation has a collection of symbols available, including `":degree:"` (colons encapsulate the collection of symbol keywords), for insertion within units notation text. +Units notation is ever useful and it is applied in one of the column labels of this table. It could potentially be difficult to format even simple things like the units of temperature. In this case we wanted to add in the temperature units of °C for the `temperature` column. Units notation has a collection of symbols available, including `":degree:"` (colons encapsulate the collection of symbol keywords), for insertion within units notation text. The example takes advantage of the available symbols and so having °C as part of a label is not too hard to express. ## Hope all your (science-y) tables are great! From e4b6fd2631711f5b766b16a84c6862c9f12faaca Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Mon, 8 Jul 2024 17:27:16 -0400 Subject: [PATCH 11/12] Ensure that nanoplots are left aligned --- docs/blog/tables-for-scientific-publishing/index.qmd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/blog/tables-for-scientific-publishing/index.qmd b/docs/blog/tables-for-scientific-publishing/index.qmd index 143ebf34a..072ad3669 100644 --- a/docs/blog/tables-for-scientific-publishing/index.qmd +++ b/docs/blog/tables-for-scientific-publishing/index.qmd @@ -144,6 +144,10 @@ gibraltar_mini = ( temp="Temperature, {{:degree:C}}", humidity="Humidity, % (RH)", ) + .cols_align( + align="left", + columns=["temp", "humidity"] + ) ) ``` From 3a904bcace9e2ee24e91e214222e86f336a67a69 Mon Sep 17 00:00:00 2001 From: Richard Iannone Date: Mon, 8 Jul 2024 17:46:01 -0400 Subject: [PATCH 12/12] Update docs/blog/tables-for-scientific-publishing/index.qmd Co-authored-by: Michael Chow --- docs/blog/tables-for-scientific-publishing/index.qmd | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/blog/tables-for-scientific-publishing/index.qmd b/docs/blog/tables-for-scientific-publishing/index.qmd index 072ad3669..4116fe58f 100644 --- a/docs/blog/tables-for-scientific-publishing/index.qmd +++ b/docs/blog/tables-for-scientific-publishing/index.qmd @@ -92,7 +92,9 @@ The combination of units notation (and chemistry notation, which is a part of th ## Nanoplots -We added the nanoplots feature to **Great Tables** in v0.4.0 (check out the [intro blog post](https://posit-dev.github.io/great-tables/blog/introduction-0.4.0/) for a quick explainer) so that tables can contain small, info-packed plots that fit reasonably well into a table context. They are interactive in that hovering over the data points provides additional plot information. This approach brings together the advantages of plots (elucidation of trends in data) and tables (access to numerical values representing the data points) in a single summary visualization. Version `0.10.0` of **Great Tables** adds the `gibraltar` dataset, which provides meteorological data (temeperature, humidity, wind speed, etc.) for the entire month of May 2024 at Gibraltar Airport Station. +We added the nanoplots feature to **Great Tables** in v0.4.0 (check out the [intro blog post](https://posit-dev.github.io/great-tables/blog/introduction-0.4.0/) for a quick explainer) so that tables can contain small, info-packed plots that fit reasonably well into a table context. They are interactive in that hovering over the data points provides additional plot information. This approach brings together the advantages of plots (elucidation of trends in data) and tables (access to numerical values representing the data points) in a single summary visualization. + +Version `0.10.0` of **Great Tables** adds the `gibraltar` dataset, which provides meteorological data (temeperature, humidity, wind speed, etc.) for the entire month of May 2024 at Gibraltar Airport Station. Nanoplots, as mentioned, are great for condensing a lot of information into a small area. Our example here with the `gibraltar` dataset takes all of the temperature and humidity data for the first 10 days of May 2023 and displays them in easy-to-explore nanoplots across two columns: