Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

visualizer interface #1062

Merged
merged 5 commits into from
Oct 8, 2024
Merged

Conversation

shivkanthb
Copy link
Contributor

Project Robyn

This PR adds a new visualization module to the Python port of Robyn. The change introduces a RobynVisualizer class with methods that correspond to the various plotting functions used in the R version of Robyn. This new module will enable the Python version to generate similar visualizations as the R version, enhancing the functionality and user experience of the Python port.

Fixes #[Issue number for Python port visualization]

Type of change

  • feat: New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • Fork the repo and create your branch from master (latest dev version).
  • The new RobynVisualizer class has been added with method declarations that mirror the R version's plotting functions.
  • No actual implementation has been added yet, so full testing will be required once the methods are implemented.
  • Ensure all existing tests pass after adding this new module.
  • Make sure the new code follows the project's coding standards and lints properly.

Note: This PR only includes the structure for the visualization module. Actual implementation of the plotting functions will be needed in subsequent PRs. Documentation updates will also be required once the implementation is complete.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 18, 2024
@shivkanthb
Copy link
Contributor Author

This is not fully ready it but more of a v0 scaffold

Copy link
Contributor

@sumane81 sumane81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

module needs to broken down into smaller, relevant plotters

python/src/robyn/visualization/visualizer.py Outdated Show resolved Hide resolved
@shivkanthb
Copy link
Contributor Author

Added different visualizer classes based on all the plots in demo.R. This is a good start and we can add more plot implementations as we encounter them.

Here's a sample oh how you would call a particular plot with the above interfaces

To call a specific plot like plot_allocator, you would use the RobynVisualizer class.

  1. First, create an instance of the RobynVisualizer class:
visualizer = RobynVisualizer()
  1. Then, you would call the plot_allocator method, passing in the necessary data:
allocator_collect = {...}  # This would be your allocator data
fig = visualizer.plot_allocator(allocator_collect)

The fig variable now contains the matplotlib Figure object, which you can display or save as needed.

remove the need for bool
@shivkanthb
Copy link
Contributor Author

the BaseVisualizer would look something like

class BaseVisualizer:
    def __init__(self):
        pass

    def _setup_plot(self):
        # Common plot setup logic
        fig, ax = plt.subplots(figsize=(10, 6))
        ax.set_xlabel('X-axis label')
        ax.set_ylabel('Y-axis label')
        ax.grid(True)
        return fig, ax

@shivkanthb
Copy link
Contributor Author

Update:
To display a plot, you could

visualizer = RobynVisualizer()
# ... set up visualizer ...
fig = visualizer.plot_adstock()
plt.show()  # This will display the plo

@shivkanthb shivkanthb requested a review from sumane81 October 7, 2024 21:39
@shivkanthb shivkanthb dismissed sumane81’s stale review October 7, 2024 21:40

They have been addressed

@shivkanthb shivkanthb merged commit 70f4560 into robynpy_release Oct 8, 2024
3 checks passed
@shivkanthb shivkanthb deleted the feature/visualization-interface branch October 8, 2024 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants