Creating gradients in graph background color, and interactive tables
Hi,
1. I am trying to create a timeseries graph where I want the graph background to show different colors for different periods e.g. months as we move along the time axis. One could imagine a timeseries 6 months long so there need to be 6 background color blocks in the graph. I tried graph tools, adding solid color boxes and clicking "send to back". However, these work when one added shape needs to be sent behind another added shape. But when it comes to the traces, the traces seem to always stay at the back of everything so the boxes are hiding them..
2. I am putting together a panel which has a table. I want the user to be able to interact with the table i.e. select a cell on the table and click a separate plot button for example to plot a graph for the parameter in the cell. I can't figure this out. Kindly help. In the past, I have made listboxes with an added integer wave for selection that allows a user to interact with the contents of the list. However, for a table, I can't work out how to make this happen and haven't found it in the reference PDFs yet. Please advise how to do this.
Thanks a lot in advance!
Peeyush
I will attach an experiment that illustrates using a table subwindow in a panel as an input device. The key is to use the GetSelection operation.
September 10, 2021 at 07:02 am - Permalink
Thanks a lot, hrodstein! I'll go through the pxp and hopefully be able to follow it for my code. Highly appreciate the help!
September 10, 2021 at 07:05 am - Permalink
You have no doubt put your color boxes in the User Front drawing layer. In the Tool Palette, click the Layer icon (second from bottom, intended to look like a stack of flat planes) to see the various layers and to set the layer you are working in. You can move a drawn object into a different layer using the contextual menu that you get when you right-click a selected object. Note the "Move to Layer" submenu near the bottom of that menu.
To set the draw layer that will be used programmatically, use the SetDrawLayer operation.
And, of course, there is an entire help file devoted to the drawing tools! DisplayHelpTopic "Drawing"
September 10, 2021 at 09:07 am - Permalink
Awesome! Thanks a lot, johnweeks! I'll do as advised. Highly appreciate the help!
September 11, 2021 at 02:35 am - Permalink
If drawing the different rectangles to indicate the months becomes too tedious, an alternative would be to display an image and then plot your data on top of the image. You can use one of Igor's image coloring modes to set the color of each of the months. Here is a simple example. First, execute this code to generate the waves:
Make/O/N=(13)/D firstDayOfMonth
firstDayOfMonth[0,11] = date2secs(2021, p+1, 1) // seconds for first day of each month
firstDayOfMonth[12] = date2secs(2022, 1, 1)
SetScale d 0, 0, "dat", firstDayOfMonth // Tell Igor that this wave contains date/time valules
Make/O/N=(12,1) monthValues = p+1
Then paste this code into the procedure window:
PauseUpdate; Silent 1 // building window...
Display /W=(35.25,41.75,737.25,362.75) data
AppendImage/L=monthLeft monthValues vs {firstDayOfMonth,*}
ModifyImage monthValues ctab= {*,*,Rainbow16,0}
ModifyGraph rgb=(0,0,0)
ModifyGraph mirror(left)=0,mirror(bottom)=0
ModifyGraph nticks(monthLeft)=0
ModifyGraph noLabel(monthLeft)=2
ModifyGraph axThick(monthLeft)=0
ModifyGraph lblPos(left)=51
ModifyGraph freePos(monthLeft)={0,bottom}
ModifyGraph dateInfo(bottom)={0,0,0}
EndMacro
Now execute:
graph0()
September 13, 2021 at 08:24 am - Permalink