|
| 1 | +# Analysis |
| 2 | + |
| 3 | +prfiesta ships with built in plots to help analyze your pull request data. These serve as a starting point in your analysis. |
| 4 | + |
| 5 | +**It's recommended to run these within the context of a [Jupyter Notebook](https://docs.jupyter.org/en/latest/)** |
| 6 | + |
| 7 | +## Built In Views |
| 8 | + |
| 9 | +| View | Description | Sample | |
| 10 | +| --------------- | --------------- | ------------- | |
| 11 | +| `prfiesta.analysis.view.view_pull_request` | Produces a table of pull requests which summarizes contribution. Each pull request is linked to enable further investigation | [Link](../notebooks/views/view_pull_requests.ipynb) | |
| 12 | + |
| 13 | +## Built In Plots |
| 14 | + |
| 15 | + Plot | Description | Sample | |
| 16 | +| --------------- | --------------- | ------ | |
| 17 | +| `prfiesta.analysis.plot.plot_overall_timeline` | Produces a plot showing contributions over time catagorized by month and year | [Link](../notebooks/plots/plot_overall_contribution_timeline.ipynb) | |
| 18 | +| `prfiesta.analysis.plot.plot_state_distribution` | Produces a plot showing the distribution of state (open or closed PR) catagorized by repository | [Link](../notebooks/plots/plot_state_distribution.ipynb) | |
| 19 | +| `prfiesta.analysis.plot.plot_author_associations` | Produces a plot showing authors association to the repository contribued to | [Link](../notebooks/plots/plot_author_association.ipynb) | |
| 20 | +| `prfiesta.analysis.plot.plot_conventional_commit_breakdown` | Produces a plot showing [git conventional commit](https://www.conventionalcommits.org/en/v1.0.0/) breakdown for contributions catagorized by repository name. Note that this requires the user to use conventional commit messages in their pull request titles. | [Link](../notebooks/plots/plot_conventional_commit_breakdown.ipynb) | |
| 21 | +| `prfiesta.analysis.plot.plot_reactions` | Produces a plot showing distribution of [GitHub Reactions](https://docs.github.com/en/rest/reactions?apiVersion=2022-11-28) | [Link](../notebooks/plots/plot_reactions.ipynb) | |
| 22 | + |
| 23 | + |
| 24 | +All prfiesta plots have the same signature: |
| 25 | + |
| 26 | +```python |
| 27 | +def plot_NAME(data: pd.DataFrame, **kwargs) -> Union[plt.Figure, plt.Axes]: |
| 28 | + ... |
| 29 | +``` |
| 30 | + |
| 31 | +*Where `NAME` is the placeholder for the actual plot name.* |
| 32 | + |
| 33 | +- The plotting functions always take a `pd.DataFrame` as the first argument. This Dataframe should originate from the prfiesta collection process. |
| 34 | +- The plotting functions always return something which can be displayed in a Jupyter Notebook |
| 35 | +- The plotting functions always take `**kwargs` which can be used to further customize the output |
| 36 | + - The exact specifics of this is up to the plotting function however in general the following common *optional* options should exist: |
| 37 | + |
| 38 | +| Option | Type | Description | |
| 39 | +| ---------------- | --------------- | --------------- | |
| 40 | +| `ax` | `Optional[matplotlib.axes.Axes]` | The `matplotlib` axis to plot into. This allows users to add the plot into a `plt.subplots`. If omitted, the plot will just plot into the default location | |
| 41 | +| `palette` | `Optional[str]` | A color palette to apply to the plot (e.g a [seaborn color palette](https://seaborn.pydata.org/tutorial/color_palettes.html)) | |
| 42 | +| `title` | `Optional[str]` | The title of the plot | |
| 43 | +| `hue` | `Optional[str]` | Used to distinguise different catagories. This is relevant to [seaborn backed plots](https://seaborn.pydata.org/tutorial/color_palettes.html?highlight=hue#vary-hue-to-distinguish-categories) | |
| 44 | + |
| 45 | + |
| 46 | +## Building a Custom Plot |
| 47 | + |
| 48 | +You can build your own plot by creating a function that follows this signature: |
| 49 | + |
| 50 | +```python |
| 51 | +from typing import Union |
| 52 | +import pandas as pd |
| 53 | +import matplotlib.pyplot as plt |
| 54 | + |
| 55 | +def plot_my_cool_plot(data: pd.DataFrame, **kwargs) -> Union[plt.Figure, plt.Axes, pd.DataFrame]: |
| 56 | + pass |
| 57 | +``` |
| 58 | + |
| 59 | +All prfiesta should accept the the same `kwargs` mentioned in the above table however implementation of these `kwargs` per plot is on a best effort basis. |
| 60 | + |
| 61 | +**If you build a plot which you think will be useful for others then feel free to contribute it to this project 🚀** |
0 commit comments