-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Heading functions can now use a Reference object
- Loading branch information
1 parent
4f3df55
commit 83bd5df
Showing
9 changed files
with
257 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
import pandas as pd | ||
|
||
import pyreball as pb | ||
import seaborn as sns | ||
|
||
pb.set_title("References to Plots and Tables") | ||
|
||
ref_ch_1 = pb.Reference() | ||
|
||
pb.print_h1("First Table", reference=ref_ch_1) | ||
|
||
N = 10 | ||
np.random.seed(1) | ||
df = pd.DataFrame({"x": np.arange(1, N + 1), "y": np.random.random(N) * 4 + 3}) | ||
pb.print_table(df, caption="A data table.") | ||
|
||
img_reference = pb.Reference() | ||
table_ref = pb.Reference() | ||
pb.print_div( | ||
f"It is also possible to create references to tables and figures. " | ||
f"For example Table {table_ref} shows sortable columns and " | ||
f"Fig. {img_reference} displays a scatterplot. " | ||
f"Each reference has a default text to be displayed, " | ||
f"but this text can be overriden by using {pb.code('__call__()')} " | ||
f"method on the reference when pasting it into the text. " | ||
f"For example, here is a link to {img_reference('Scatterplot')}." | ||
) | ||
pb.print_table( | ||
df, caption="A sortable table with a reference", reference=table_ref, sortable=True | ||
) | ||
|
||
pb.print_table( | ||
df, caption="A table sorted by y column", sorting_definition=("y", "asc") | ||
) | ||
|
||
pb.print_h1("Charts") | ||
|
||
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_div( | ||
f"Note that you can use the references in your text multiple times, " | ||
f"see again the reference to Table {table_ref} and Fig. {img_reference}. " | ||
f"Of course, we cannot assign a single reference to multiple tables or figures. " | ||
f"Last, but not least, one can use reference to Chapter {ref_ch_1}. " | ||
f"Again, we can override the text and create a link to {ref_ch_1('First Chapter')}." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# References | ||
|
||
TBD | ||
To create anchors to various items on the HTML page, it is possible to use [`Reference`](../api/pyreball_html/#pyreball.html.Reference) class. | ||
|
||
{{ inline_source("docs/examples/references.py") }} | ||
|
||
<iframe style="border:2px solid;" src="../examples/references.html" height="800" width="100%" title="Iframe Example"></iframe> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.