Skip to content

Commit 9d42f02

Browse files
committed
add grid option to strain plot
1 parent a79a070 commit 9d42f02

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

GSASII/GSASIIplot.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
1.0, 1.0), (1.0, 0.69411766529083252, 0.69411766529083252)]}
154154
'''In matplotlib 2.0.x+ the Paired color map was dumbed down to 16 colors.
155155
_Old_Paired_data is the pre-2.0 Paired color map found in
156-
matplotlib._cm.py and is used to creat color map GSPaired.
156+
matplotlib._cm.py and is used to create color map GSPaired.
157157
158158
This can be done on request for other color maps. N.B. any new names
159159
must be explicitly added to the color list obtained from
@@ -2877,6 +2877,11 @@ def Draw():
28772877
def PlotStrain(G2frame,data,newPlot=False):
28782878
'''plot of strain data, used for diagnostic purposes
28792879
'''
2880+
def OnKeyPress(event):
2881+
if event.key == 'g':
2882+
mpl.rcParams['axes.grid'] = not mpl.rcParams['axes.grid']
2883+
PlotStrain(G2frame,data,True)
2884+
28802885
def OnMotion(event):
28812886
xpos = event.xdata
28822887
if xpos: #avoid out of frame mouse position
@@ -2894,8 +2899,10 @@ def OnMotion(event):
28942899
else:
28952900
newPlot = True
28962901
Page.canvas.mpl_connect('motion_notify_event', OnMotion)
2902+
Page.canvas.mpl_connect('key_press_event', OnKeyPress)
2903+
Page.Choice = ('g: toggle grid',)
28972904

2898-
Page.Choice = None
2905+
Page.keyPress = OnKeyPress
28992906
G2frame.G2plotNB.status.DestroyChildren() #get rid of special stuff on status bar
29002907
Plot.set_title('Strain')
29012908
Plot.set_ylabel(r'd-spacing',fontsize=14)
@@ -3216,13 +3223,13 @@ def OnKeyPress(event):
32163223
Page.Choice = (' key press','e: toggle error bars','g: toggle grid','s: save as .csv file')
32173224
else:
32183225
Page.Choice = (' key press','g: toggle grid','s: save as .csv file')
3219-
Page.keyPress = OnKeyPress
32203226
if not new:
32213227
if not G2frame.G2plotNB.allowZoomReset: # save previous limits
32223228
xylim = copy.copy(lim)
32233229
else:
32243230
Page.canvas.mpl_connect('motion_notify_event', OnMotion)
32253231
Page.canvas.mpl_connect('key_press_event', OnKeyPress)
3232+
Page.keyPress = OnKeyPress
32263233
G2frame.G2plotNB.SetHelpButton(G2frame.dataWindow.helpKey)
32273234
# save information needed to reload from tree and redraw
32283235
G2frame.G2plotNB.RegisterRedrawRoutine(G2frame.G2plotNB.lastRaisedPlotTab,
@@ -5598,7 +5605,7 @@ def OnImRelease(event):
55985605
Plot.text(cent[0],cent[1],'+',color=col,ha='center',va='center')
55995606
elif tth: #future hyperbola plot
56005607
dsp =0.5*Data['wavelength']/npsind(tth/2.0)
5601-
darc = Data['rotation']
5608+
# darc = Data['rotation']
56025609
# Azm = np.arange(-10.-darc,190.5-darc,.5)
56035610
Azm = np.arange(0.,360.5,.5)
56045611
xyH = []

0 commit comments

Comments
 (0)