Skip to content

Commit 3dd616b

Browse files
committed
closer to PR #285: preserves plot x-range in sharedX mode, but not y-scaling across refinements
1 parent 820fe17 commit 3dd616b

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

GSASII/GSASIIpwdplot.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,13 +1503,13 @@ def refPlotUpdate(Histograms,cycle=None,restore=False):
15031503
updates the curves, not the reflection marks or the legend.
15041504
It should be called with restore=True to reset plotting
15051505
parameters after the refinement is done.
1506+
1507+
Note that the Page.plotStyle values are stashed in G2frame
1508+
to be restored later
15061509
'''
15071510
if restore:
15081511
(G2frame.SinglePlot,G2frame.Contour,G2frame.Weight,
1509-
G2frame.plusPlot,G2frame.SubBack,Page.plotStyle['logPlot'],
1510-
Page.plotStyle['qPlot'],Page.plotStyle['dPlot']) = savedSettings
1511-
# Also save to G2frame so settings survive Page recreation during ResetPlots (MG/Cl Sonnet)
1512-
G2frame.savedPlotStyle = copy.copy(Page.plotStyle)
1512+
G2frame.plusPlot,G2frame.SubBack,G2frame.savedPlotStyle) = savedSettings
15131513
return
15141514

15151515
if plottingItem not in Histograms:
@@ -1832,19 +1832,15 @@ def onGroupXlimChanged(ax):
18321832
if G2frame.Contour: publish = None
18331833

18341834
new,plotNum,Page,Plot,limits = G2frame.G2plotNB.FindPlotTab('Powder Patterns','mpl')
1835+
if hasattr(G2frame, 'savedPlotStyle'):
1836+
Page.plotStyle.update(G2frame.savedPlotStyle)
1837+
del G2frame.savedPlotStyle # do this only once
18351838
Page.toolbar.setPublish(publish)
18361839
Page.toolbar.arrows['_groupMode'] = None
18371840
# if we are changing histogram types (including group to individual, reset plot)
18381841
if not new and hasattr(Page,'prevPlotType'):
18391842
if Page.prevPlotType != plottype: new = True
18401843
Page.prevPlotType = plottype
1841-
1842-
# Restore saved plot style settings (qPlot, dPlot, logPlot) if they were preserved
1843-
# across a refinement cycle. These get saved in refPlotUpdate(restore=True) and
1844-
# need to be applied here because Page may have been recreated by ResetPlots. (based on MG/Cl Sonnet)
1845-
if hasattr(G2frame, 'savedPlotStyle'):
1846-
Page.plotStyle.update(G2frame.savedPlotStyle)
1847-
del G2frame.savedPlotStyle # Clear after applying
18481844

18491845
if G2frame.ifSetLimitsMode and G2frame.GPXtree.GetItemText(G2frame.GPXtree.GetSelection()) == 'Limits':
18501846
# note mode
@@ -1912,8 +1908,8 @@ def onGroupXlimChanged(ax):
19121908
plottingItem = G2frame.GPXtree.GetItemText(G2frame.PatternId)
19131909
# save settings to be restored after refinement with repPlotUpdate({},restore=True)
19141910
savedSettings = (G2frame.SinglePlot,G2frame.Contour,G2frame.Weight,
1915-
G2frame.plusPlot,G2frame.SubBack,Page.plotStyle['logPlot'],
1916-
Page.plotStyle['qPlot'],Page.plotStyle['dPlot'])
1911+
G2frame.plusPlot,G2frame.SubBack,
1912+
copy.deepcopy(Page.plotStyle))
19171913
G2frame.SinglePlot = True
19181914
G2frame.Contour = False
19191915
G2frame.Weight = True
@@ -2321,20 +2317,21 @@ def onGroupXlimChanged(ax):
23212317
DZmin = min(DZmin,DZ.min())
23222318
DZmax = max(DZmax,DZ.max())
23232319
totalrange += gXmax[i]-gXmin[i]
2324-
# apportion axes lengths so that units are equal
2325-
xfrac = [(gXmax[i]-gXmin[i])/totalrange for i in range(Page.groupN)]
2326-
GS_kw = {'height_ratios':[4, 1], 'width_ratios':xfrac,}
23272320
if plotOpt['sharedX'] and (
23282321
Page.plotStyle['qPlot'] or Page.plotStyle['dPlot']):
23292322
Page.figure.text(0.001,0.94,'X shared',fontsize=11,
23302323
color='g')
2324+
GS_kw = {'height_ratios':[4, 1]}
23312325
#Plots = Page.figure.subplots(2,Page.groupN,sharey='row',sharex=True,
23322326
# gridspec_kw=GS_kw)
23332327
# Don't use sharey='row' when sharedX - we'll manage y-limits manually
23342328
# This avoids conflicts between sharey and our dynamic y-limit updates
23352329
Plots = Page.figure.subplots(2,Page.groupN,sharex=True,
23362330
gridspec_kw=GS_kw)
23372331
else:
2332+
# apportion axes lengths making some plots bigger so that initially units are equal
2333+
xfrac = [(gXmax[i]-gXmin[i])/totalrange for i in range(Page.groupN)]
2334+
GS_kw = {'height_ratios':[4, 1], 'width_ratios':xfrac,}
23382335
Plots = Page.figure.subplots(2,Page.groupN,sharey='row',sharex='col',
23392336
gridspec_kw=GS_kw)
23402337
Page.figure.subplots_adjust(left=5/100.,bottom=16/150.,

0 commit comments

Comments
 (0)