Skip to content

Commit 3985cbe

Browse files
committed
make sharing X-axes an option for grouped plots
1 parent 0c00d51 commit 3985cbe

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

GSASII/GSASIIpwdplot.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
plotOpt['lineWid'] = '1'
8484
plotOpt['saveCSV'] = False
8585
plotOpt['CSVfile'] = None
86+
plotOpt['GroupedX'] = False
8687
for xy in 'x','y':
8788
for minmax in 'min','max':
8889
key = f'{xy}{minmax}'
@@ -224,6 +225,10 @@ def OnPlotKeyPress(event):
224225
Page.plotStyle['title'] = not Page.plotStyle.get('title',True)
225226
elif event.key == 'f' and 'PWDR' in plottype: # short or full length tick-marks
226227
Page.plotStyle['flTicks'] = not Page.plotStyle.get('flTicks',False)
228+
elif event.key == 'x'and groupName is not None:
229+
plotOpt['GroupedX'] = not plotOpt['GroupedX']
230+
if not plotOpt['GroupedX']: # reset scale
231+
newPlot = True
227232
elif event.key == 'x'and 'PWDR' in plottype:
228233
Page.plotStyle['exclude'] = not Page.plotStyle['exclude']
229234
elif event.key == '.':
@@ -2014,7 +2019,8 @@ def onPartialConfig(event):
20142019
Page.Choice = [' key press',
20152020
'f: toggle full-length ticks','g: toggle grid',
20162021
's: toggle sqrt plot',
2017-
'q: toggle Q plot','t: toggle d-spacing plot']
2022+
'q: toggle Q plot','t: toggle d-spacing plot',
2023+
'x: share x-axes']
20182024
Plot.set_visible(False) # removes "big" plot
20192025
gXmin = {}
20202026
gXmax = {}
@@ -2072,8 +2078,11 @@ def onPartialConfig(event):
20722078
# apportion axes lengths so that units are equal
20732079
xfrac = [(gXmax[i]-gXmin[i])/totalrange for i in range(nx)]
20742080
GS_kw = {'height_ratios':[4, 1], 'width_ratios':xfrac,}
2075-
2076-
Plots = Page.figure.subplots(2,nx,sharey='row',sharex='col',
2081+
if plotOpt['GroupedX']:
2082+
Plots = Page.figure.subplots(2,nx,sharey='row',sharex=True,
2083+
gridspec_kw=GS_kw)
2084+
else:
2085+
Plots = Page.figure.subplots(2,nx,sharey='row',sharex='col',
20772086
gridspec_kw=GS_kw)
20782087
Page.figure.subplots_adjust(left=5/100.,bottom=16/150.,
20792088
right=.99,top=1.-3/200.,hspace=0,wspace=0)

0 commit comments

Comments
 (0)