Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pyicon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nils Brüggemann
pyicon
Commits
6e3ca932
Commit
6e3ca932
authored
1 month ago
by
Nils Brüggemann
Committed by
Fraser William Goldsworth
1 month ago
Browse files
Options
Downloads
Patches
Plain Diff
Button to save a figure.
parent
78e9a809
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!43
Allow users to set projection with cartopy projection object
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/pyic_view.py
+14
-0
14 additions, 0 deletions
scripts/pyic_view.py
with
14 additions
and
0 deletions
scripts/pyic_view.py
+
14
−
0
View file @
6e3ca932
...
...
@@ -149,6 +149,7 @@ class view(object):
self
.
selected_cmap
=
tk
.
StringVar
(
value
=
self
.
colormaps
[
0
])
self
.
color_limits
=
tk
.
StringVar
(
value
=
"
auto
"
)
# Default color limits
self
.
lon_lat_reg_tk
=
tk
.
StringVar
(
value
=
"
-180,180,-90,90
"
)
self
.
save_fig_tk
=
tk
.
StringVar
(
value
=
"
./fig.pdf
"
)
self
.
selected_res
=
tk
.
StringVar
(
value
=
"
0.3
"
)
self
.
selected_proj
=
tk
.
StringVar
(
value
=
"
None
"
)
...
...
@@ -217,6 +218,12 @@ class view(object):
command
=
self
.
activate_zoom
)
self
.
zoom_button
.
grid
(
row
=
3
,
column
=
2
)
# save_fig entry
entry
=
tk
.
Entry
(
root
,
textvariable
=
self
.
save_fig_tk
)
entry
.
grid
(
row
=
4
,
column
=
1
)
entry
.
insert
(
0
,
""
)
# Default value
entry
.
bind
(
"
<Return>
"
,
self
.
save_figure
)
# Update when pressing Enter
# Variables to store zoom area
self
.
press_event
=
None
self
.
rect
=
None
...
...
@@ -247,6 +254,13 @@ class view(object):
root
.
mainloop
()
return
# for saving the figure
def
save_figure
(
self
,
*
args
):
fpath
=
self
.
save_fig_tk
.
get
()
print
(
f
'
Saving figure
{
fpath
}
'
)
#plt.savefig(fpath, dpi=300)
plt
.
savefig
(
fpath
,
dpi
=
300
,
bbox_inches
=
'
tight
'
)
# for zoom
def
activate_zoom
(
self
):
"""
Activates zooming mode by connecting event handlers.
"""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment