-
Notifications
You must be signed in to change notification settings - Fork 2
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
. #5
Open
RohanBhattaraiNP
wants to merge
6
commits into
Theodlz:main
Choose a base branch
from
RohanBhattaraiNP:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
. #5
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cc32252
Create file
RohanBhattaraiNP af374ca
Basic GUI design
RohanBhattaraiNP ecca3f4
Update GUI.py
RohanBhattaraiNP c32403a
Update GUI.py
RohanBhattaraiNP 6191876
Create ui.py
RohanBhattaraiNP f844aa5
Update ui.py
RohanBhattaraiNP File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import tkinter as tk | ||
from tkinter import ttk | ||
from datetime import date | ||
import matplotlib.pyplot as plt | ||
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg | ||
import seaborn as sns | ||
import numpy as np | ||
import pandas as pd | ||
|
||
def plot_histograms(ax1, ax2): | ||
""" | ||
Plot histograms on the given axes. | ||
|
||
Parameters: | ||
ax1 (matplotlib.axes.Axes): The first axes object. | ||
ax2 (matplotlib.axes.Axes): The second axes object. | ||
""" | ||
data = np.random.randn(100, 2) | ||
|
||
ax1.clear() | ||
ax1.hist(data[:, 0], color='skyblue', bins=10) | ||
ax1.set_title('Histogram 1') | ||
ax1.set_xlabel('Values') | ||
ax1.set_ylabel('Frequency') | ||
ax1.grid(True) | ||
|
||
ax2.clear() | ||
ax2.hist(data[:, 1], color='salmon', bins=10) | ||
ax2.set_title('Histogram 2') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might want the title to be an argument you pass to the plot_data() method or smth |
||
ax2.set_xlabel('Values') | ||
ax2.set_ylabel('Frequency') | ||
ax2.grid(True) | ||
|
||
def plot_corner_plot(ax3): | ||
""" | ||
Plot a corner plot on the given axes. | ||
|
||
Parameters: | ||
ax3 (matplotlib.axes.Axes): The axes object. | ||
""" | ||
data = np.random.randn(100, 2) | ||
|
||
ax3.clear() | ||
pair_plot = sns.pairplot(pd.DataFrame(data)) | ||
pair_plot.fig.suptitle('Corner Plot', y=1.02) | ||
pair_plot.fig.set_size_inches(6, 6) | ||
|
||
def plot_data(ax1, ax2, ax3, canvas): | ||
""" | ||
Plot data including histograms and corner plot. | ||
|
||
Parameters: | ||
ax1 (matplotlib.axes.Axes): The first axes object. | ||
ax2 (matplotlib.axes.Axes): The second axes object. | ||
ax3 (matplotlib.axes.Axes): The third axes object. | ||
canvas (FigureCanvasTkAgg): The canvas object. | ||
""" | ||
plot_histograms(ax1, ax2) | ||
plot_corner_plot(ax3) | ||
canvas.draw() | ||
|
||
def main(): | ||
""" | ||
Main function to create GUI and run the application. | ||
""" | ||
root = tk.Tk() | ||
root.title("Dropdowns and Plots") | ||
|
||
options = ['Option 1', 'Option 2', 'Option 3'] | ||
dropdown1_label = ttk.Label(root, text="Dropdown 1:") | ||
dropdown1_label.grid(row=0, column=0, padx=5, pady=5, sticky="w") | ||
dropdown1 = ttk.Combobox(root, values=options) | ||
dropdown1.grid(row=0, column=1, padx=5, pady=5) | ||
dropdown1.current(0) | ||
|
||
dropdown2_label = ttk.Label(root, text="Dropdown 2:") | ||
dropdown2_label.grid(row=1, column=0, padx=5, pady=5, sticky="w") | ||
dropdown2 = ttk.Combobox(root, values=options) | ||
dropdown2.grid(row=1, column=1, padx=5, pady=5) | ||
dropdown2.current(0) | ||
|
||
fig, ((ax1, ax2), (ax3, _)) = plt.subplots(2, 2, figsize=(10, 6), dpi=100) | ||
canvas = FigureCanvasTkAgg(fig, master=root) | ||
canvas.get_tk_widget().grid(row=4, column=0, columnspan=2, padx=5, pady=5, sticky="nsew") | ||
root.grid_rowconfigure(4, weight=1) | ||
root.grid_columnconfigure(0, weight=1) | ||
|
||
# Add a vertical scrollbar | ||
scrollbar = ttk.Scrollbar(root, command=canvas.get_tk_widget().yview) | ||
scrollbar.grid(row=4, column=2, sticky="ns") | ||
canvas.get_tk_widget().configure(yscrollcommand=scrollbar.set) | ||
|
||
submit_button = ttk.Button(root, text="Submit", command=lambda: plot_data(ax1, ax2, ax3, canvas)) | ||
submit_button.grid(row=2, column=0, columnspan=2, padx=5, pady=10) | ||
|
||
today_date = date.today().strftime("%B %d, %Y") | ||
date_label = ttk.Label(root, text="Today's Date: " + today_date) | ||
date_label.grid(row=3, column=0, columnspan=2, padx=5, pady=5) | ||
|
||
# Make the application responsive | ||
root.grid_rowconfigure(0, weight=0) | ||
root.grid_rowconfigure(1, weight=0) | ||
root.grid_rowconfigure(2, weight=0) | ||
root.grid_rowconfigure(3, weight=0) | ||
root.grid_rowconfigure(4, weight=1) | ||
|
||
root.grid_columnconfigure(0, weight=1) | ||
root.grid_columnconfigure(1, weight=1) | ||
|
||
root.mainloop() | ||
|
||
if __name__ == "__main__": | ||
main() |
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,113 @@ | ||
import tkinter as tk | ||
from tkinter import ttk | ||
from datetime import date | ||
import matplotlib.pyplot as plt | ||
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg | ||
import seaborn as sns | ||
import numpy as np | ||
import pandas as pd | ||
|
||
def plot_histograms(ax1, ax2): | ||
""" | ||
Plot histograms on the given axes. | ||
|
||
Parameters: | ||
ax1 (matplotlib.axes.Axes): The first axes object. | ||
ax2 (matplotlib.axes.Axes): The second axes object. | ||
""" | ||
data = np.random.randn(100, 2) | ||
|
||
ax1.clear() | ||
ax1.hist(data[:, 0], color='skyblue', bins=10) | ||
ax1.set_title('Histogram 1') | ||
ax1.set_xlabel('Values') | ||
ax1.set_ylabel('Frequency') | ||
ax1.grid(True) | ||
|
||
ax2.clear() | ||
ax2.hist(data[:, 1], color='salmon', bins=10) | ||
ax2.set_title('Histogram 2') | ||
ax2.set_xlabel('Values') | ||
ax2.set_ylabel('Frequency') | ||
ax2.grid(True) | ||
|
||
def plot_corner_plot(ax3): | ||
""" | ||
Plot a corner plot on the given axes. | ||
|
||
Parameters: | ||
ax3 (matplotlib.axes.Axes): The axes object. | ||
""" | ||
data = np.random.randn(100, 2) | ||
|
||
ax3.clear() | ||
pair_plot = sns.pairplot(pd.DataFrame(data)) | ||
pair_plot.fig.suptitle('Corner Plot', y=1.02) | ||
pair_plot.fig.set_size_inches(6, 6) | ||
|
||
def plot_data(ax1, ax2, ax3, canvas): | ||
""" | ||
Plot data including histograms and corner plot. | ||
|
||
Parameters: | ||
ax1 (matplotlib.axes.Axes): The first axes object. | ||
ax2 (matplotlib.axes.Axes): The second axes object. | ||
ax3 (matplotlib.axes.Axes): The third axes object. | ||
canvas (FigureCanvasTkAgg): The canvas object. | ||
""" | ||
plot_histograms(ax1, ax2) | ||
plot_corner_plot(ax3) | ||
canvas.draw() | ||
|
||
def main(): | ||
""" | ||
Main function to create GUI and run the application. | ||
""" | ||
root = tk.Tk() | ||
root.title("Dropdowns and Plots") | ||
|
||
options = ['Filter 1', 'Filter 2', 'Filter 3'] | ||
dropdown1_label = ttk.Label(root, text="List of Filters 1:") | ||
dropdown1_label.grid(row=0, column=0, padx=5, pady=5, sticky="w") | ||
dropdown1 = ttk.Combobox(root, values=options) | ||
dropdown1.grid(row=0, column=1, padx=5, pady=5) | ||
dropdown1.current(0) | ||
|
||
dropdown2_label = ttk.Label(root, text="List of Filter 2:") | ||
dropdown2_label.grid(row=1, column=0, padx=5, pady=5, sticky="w") | ||
dropdown2 = ttk.Combobox(root, values=options) | ||
dropdown2.grid(row=1, column=1, padx=5, pady=5) | ||
dropdown2.current(0) | ||
|
||
fig, ((ax1, ax2), (ax3, _)) = plt.subplots(2, 2, figsize=(10, 6), dpi=100) | ||
canvas = FigureCanvasTkAgg(fig, master=root) | ||
canvas.get_tk_widget().grid(row=4, column=0, columnspan=2, padx=5, pady=5, sticky="nsew") | ||
root.grid_rowconfigure(4, weight=1) | ||
root.grid_columnconfigure(0, weight=1) | ||
|
||
# Add a vertical scrollbar | ||
scrollbar = ttk.Scrollbar(root, command=canvas.get_tk_widget().yview) | ||
scrollbar.grid(row=4, column=2, sticky="ns") | ||
canvas.get_tk_widget().configure(yscrollcommand=scrollbar.set) | ||
|
||
submit_button = ttk.Button(root, text="Submit", command=lambda: plot_data(ax1, ax2, ax3, canvas)) | ||
submit_button.grid(row=2, column=0, columnspan=2, padx=5, pady=10) | ||
|
||
today_date = date.today().strftime("%B %d, %Y") | ||
date_label = ttk.Label(root, text="Today's Date: " + today_date) | ||
date_label.grid(row=3, column=0, columnspan=2, padx=5, pady=5) | ||
|
||
# Make the application responsive | ||
root.grid_rowconfigure(0, weight=0) | ||
root.grid_rowconfigure(1, weight=0) | ||
root.grid_rowconfigure(2, weight=0) | ||
root.grid_rowconfigure(3, weight=0) | ||
root.grid_rowconfigure(4, weight=1) | ||
|
||
root.grid_columnconfigure(0, weight=1) | ||
root.grid_columnconfigure(1, weight=1) | ||
|
||
root.mainloop() | ||
|
||
if __name__ == "__main__": | ||
main() |
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 @@ | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Empty file, please remove |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep your imports PEP compliant, meaning classic imports (
import ...
) first (sorted alphabetical) and thenfrom ... import ...
.