Change X-axis resolution

Posted on
Sun Mar 19, 2017 2:24 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Change X-axis resolution

Hi Karl.
I see in some of your examples that you have a different resolution for the X-axis. On my plots I get every third hour marked on the X-axis.
I have gone trough the manual, but I cant find out how to change this? Can you explain? See examples below...
Attachments
Skjermbilde 2017-03-19 kl. 09.21.02.png
Skjermbilde 2017-03-19 kl. 09.21.02.png (67.26 KiB) Viewed 4659 times
Skjermbilde 2017-03-19 kl. 09.21.19.png
Skjermbilde 2017-03-19 kl. 09.21.19.png (39.46 KiB) Viewed 4659 times

Håvard

Posted on
Sun Mar 19, 2017 12:07 pm
kw123 offline
User avatar
Posts: 8335
Joined: May 12, 2013
Location: Dallas, TX

Re: Change X-axis resolution

Will put some time into it next week. Was busy finishing the pro I sensor.


Sent from my iPhone using Tapatalk

Posted on
Sun Dec 31, 2017 12:15 pm
mbordas offline
Posts: 15
Joined: Dec 28, 2016

Re: Change X-axis resolution

Was the ability to change the tick marks on the x-axis added? I can't find it..

Thanks.

Posted on
Sun Dec 31, 2017 2:02 pm
kw123 offline
User avatar
Posts: 8335
Joined: May 12, 2013
Location: Dallas, TX

Re: Change X-axis resolution

No not yet in general. ...
But in gnuplot you could do it by putting the format string into the xscale format field. Not for matplot though

There are really many parameters that can / need to be set
It depends on x resolution , which plot , and how many hours/ days.

If you have a specific suggestion I can look at it.


Sent from my iPhone using Tapatalk

Posted on
Sun Mar 18, 2018 1:12 pm
mbordas offline
Posts: 15
Joined: Dec 28, 2016

Re: Change X-axis resolution

Ok, I got gnuplot installed and working. Cool, it already looks better than matplot, and it's a lot faster! Can you explain more how to use the xscale format string? It looks like I have to switch the "Data Source for LINES" from the automatic "Time-series from Devices" to "Data in Variable/File" to even get the X Scale fields to show up. But I don't know what to put in that file.

I'm trying to graph a 6 day period, but I want more frequent tick marks. The default behavior only lables the days, i.e. Thurs, Fri, Sat, Sun. I want to add the hours so I can more easily see what time of day events happened. Ideally something like every 4 hours. This is what it looks like now:
Attachments
Bathroom Plot 6 day-minute-S2.png
Bathroom Plot 6 day-minute-S2.png (44.64 KiB) Viewed 4271 times

Posted on
Sun Mar 18, 2018 2:24 pm
kw123 offline
User avatar
Posts: 8335
Joined: May 12, 2013
Location: Dallas, TX

Re: Change X-axis resolution

in std plots you can currently NOT change the format .. only when using external files (data source for lines in plots) you can set from:to and format (either eg %3.1f or %d%m-%h%M%S )

its on my to do list ..


Karl

Posted on
Sun Mar 18, 2018 6:41 pm
kw123 offline
User avatar
Posts: 8335
Joined: May 12, 2013
Location: Dallas, TX

Re: Change X-axis resolution

actually it was much easier. have it ready for gnu plot

have defined a format field for each plot (minutes/.hours/days):

date/timeformat+ticksEverySecs

eg
%H:%M+3*3600

would print hours:minutes every 3 hours

Is that ok?

Karl

Posted on
Sun Mar 18, 2018 7:13 pm
kw123 offline
User avatar
Posts: 8335
Joined: May 12, 2013
Location: Dallas, TX

Re: Change X-axis resolution

download in plugin store: https://www.indigodomo.com/pluginstore/71/

Karl


ONLY FOR GNUPLOT and somewhat tested ..

Posted on
Mon Mar 19, 2018 7:02 am
mbordas offline
Posts: 15
Joined: Dec 28, 2016

Re: Change X-axis resolution

Woa, awesome! Thanks for adding that so fast. It works great! The only issue I noticed is any change I make to the format xscale applies to all my plots, not just the one I'm currently editing. Not sure if that's a bug or if it has to be that way for some reason. It's not a big deal for me since I want the same format for all my plots, but just so you know!

Thanks!

Posted on
Mon Mar 19, 2018 9:04 am
kw123 offline
User avatar
Posts: 8335
Joined: May 12, 2013
Location: Dallas, TX

Re: Change X-axis resolution

No that should not be the case. Will check.


Sent from my iPhone using Tapatalk

Posted on
Mon Mar 19, 2018 9:26 am
kw123 offline
User avatar
Posts: 8335
Joined: May 12, 2013
Location: Dallas, TX

Re: Change X-axis resolution

where do you see the change, in plot device edit or in the plots?

could you be so kind and check some other gnuplotfiles:
/Users/>>yourid<</indigo/INDIGOplotD/gnu/>>someplotname<<minute-S1.gnu

look for
set format x ....
set xtics ....

they should not all be the same.

I do NOT see that in my plots

thanks for testing
Karl

Posted on
Mon Mar 19, 2018 11:31 am
mbordas offline
Posts: 15
Joined: Dec 28, 2016

Re: Change X-axis resolution

I was seeing the same values in the .gnu files for all my plots. I restarted my computer and now it's behaving correctly, I've modified the values so each plot is different.

So never mind, it was just some weird transient issue..

Thanks!

Posted on
Mon Mar 19, 2018 11:50 am
kw123 offline
User avatar
Posts: 8335
Joined: May 12, 2013
Location: Dallas, TX

Change X-axis resolution

thanks for checking..

trying to mirror this in matplot, but that uses a completely different schema
MATPLOT uses python methods to set these parameters
Code: Select all
                try:
                    ticksDensity = float(plotN["MHDFormat"][tType])
                except:
                    ticksDensity = 1
               
                if tType == 0:
                    if   int(plotN["MHDDays"][0]) ==1: fraction = 0.125
                    elif int(plotN["MHDDays"][0]) ==2: fraction = 0.125
                    elif int(plotN["MHDDays"][0]) ==3: fraction = 0.25
                    elif int(plotN["MHDDays"][0]) ==4: fraction = 0.25
                    elif int(plotN["MHDDays"][0]) ==5: fraction = 0.5
                    elif int(plotN["MHDDays"][0]) ==6: fraction = 0.5
                    elif int(plotN["MHDDays"][0]) ==7: fraction = 0.5
                    elif int(plotN["MHDDays"][0]) < 15: fraction = 1
                    elif int(plotN["MHDDays"][0]) < 31: fraction = 11
                    else :                         fraction  = 11

                    if fraction < 10:
                        ax.xaxis.set_major_formatter(DateFormatter("%a"))
                        ax.xaxis.set_major_locator(DayLocator())
                        minorLocator   = MultipleLocator(fraction/ticksDensity)
                        ax.xaxis.set_minor_locator(minorLocator)
                        if plotN["ampm"] =="24":
                            if fraction >0.25:
                                ax.xaxis.set_minor_formatter(DateFormatter("%H"))
                            else:
                                ax.xaxis.set_minor_formatter(DateFormatter("%H:%M"))
                        else:
                            if fraction >0.25:
                                ax.xaxis.set_minor_formatter(DateFormatter("%l"))
                            else:
                                ax.xaxis.set_minor_formatter(DateFormatter("%l %p"))
                    else:
                        ax.xaxis.set_major_formatter(DateFormatter("#"))
                        ax.xaxis.set_major_locator(WeekdayLocator(byweekday=0, interval=1, tz=None))  # always do monday for >= 2 weeks
                        ax.xaxis.set_minor_formatter(DateFormatter("%a"))
                        ax.xaxis.set_minor_locator(DayLocator(interval=2, tz=None))

                if tType == 1:
                    if countTimeBinsMax < 24*10:
                        ax.xaxis.set_major_formatter(DateFormatter("%a"))
                        ax.xaxis.set_major_locator(DayLocator())
                        ax.xaxis.set_minor_locator(HourLocator(byhour=(0,12), tz=None))
                        ax.xaxis.set_minor_formatter(DateFormatter("%H"))
                    elif countTimeBinsMax < 24*21 :
                        ax.xaxis.set_major_formatter(DateFormatter("#"))
                        ax.xaxis.set_major_locator(WeekdayLocator(byweekday=0, interval=1, tz=None))
                        ax.xaxis.set_minor_locator(DayLocator())
                        ax.xaxis.set_minor_formatter(DateFormatter("%a"))
                    elif countTimeBinsMax < 24*40:
                        ax.xaxis.set_major_formatter(DateFormatter("#"))
                        ax.xaxis.set_major_locator(WeekdayLocator(byweekday=0, interval=1, tz=None))  # always do monday for >= 2 weeks
                        ax.xaxis.set_minor_formatter(DateFormatter("%a"))
                        ax.xaxis.set_minor_locator(DayLocator(interval=2, tz=None))
                    elif countTimeBinsMax < 24*60:
                        ax.xaxis.set_major_formatter(DateFormatter("%b"))
                        ax.xaxis.set_major_locator(MonthLocator())
                        ax.xaxis.set_minor_formatter(DateFormatter("%a"))
                        ax.xaxis.set_minor_locator(DayLocator(interval=4, tz=None))
                    else:
                        ax.xaxis.set_major_formatter(DateFormatter("%b"))
                        ax.xaxis.set_major_locator(MonthLocator())
                        ax.xaxis.set_minor_formatter(DateFormatter("%a"))
                        ax.xaxis.set_minor_locator(DayLocator(interval=10, tz=None))

                if tType == 2:
                    if countTimeBinsMax < 121 :
                        ax.xaxis.set_major_formatter(DateFormatter("%b"))
                        ax.xaxis.set_major_locator(MonthLocator())
                        ax.xaxis.set_minor_locator(WeekdayLocator(byweekday=0, interval=1, tz=None))
                        ax.xaxis.set_minor_formatter(DateFormatter("%a-%d"))
                    elif countTimeBinsMax < 241 :
                        ax.xaxis.set_major_formatter(DateFormatter("%b"))
                        ax.xaxis.set_major_locator(MonthLocator())
                        ax.xaxis.set_minor_locator(WeekdayLocator(byweekday=0, interval=1, tz=None))
                        ax.xaxis.set_minor_formatter(DateFormatter("%d"))
                    elif countTimeBinsMax < 390 :
                        ax.xaxis.set_major_formatter(DateFormatter("%b"))
                        ax.xaxis.set_major_locator(MonthLocator())
                    else:
                        pass  #  leave it to MATPLOT



vs GNUPLOT you have to create a file with format statements
Code: Select all
        try: # dont use  it if it is a number, then it is meant for matplot 
            int(MHDFormat)
            MHDFormat =""
        except: pass
        xx = MHDFormat.split("+")
       
        if len(xx) == 1:
            overWriteXFormat = [MHDFormat,""]
        elif len(xx) > 1:
            overWriteXFormat = xx
        else:
            overWriteXFormat = ["",""]
...
                    if theType ==u"day":
                        f.write((u"set timefmt \"%Y%m%d\" \n").encode('utf8'))                  # yyyymmdd x axis input data format
                        if int(self.PLOT[nPlot]["MHDDays"][2]) >0:   f.write((u"set xrange[\""+earliestDay+u"\":\""+lastDay+u"\"]\n").encode('utf8'))


                        if len(overWriteXFormat[0]) > 3:
                            f.write((u"set format x \""+ overWriteXFormat[0] +"\"  \n").encode('utf8'))                     # x axis dat format on plot
                        else:
                            f.write((u"set format x \"%b\" \n").encode('utf8'))                     # x axis dat format on plot
                        if len(overWriteXFormat[1]) > 0 :
                       
                            f.write((u"set xtics "+ overWriteXFormat[1] +" \n").encode('utf8'))            # x axis dat format on plot


                    if theType =="hour":
                        f.write((u"set timefmt \"%Y%m%d%H\"    \n").encode('utf8'))                  # yyyymmddhh
                        if int(self.PLOT[nPlot]["MHDDays"][1]) >0:   f.write((u"set xrange[\""+earliestDay+u"\":\""+lastDay+u"\"]\n").encode('utf8'))

                        if len(overWriteXFormat[0]) > 3 :
                            f.write((u"set format x \""+ overWriteXFormat[0] +"\"  \n").encode('utf8'))                     # x axis dat format on plot
                        else:
                            if int(self.PLOT[nPlot]["MHDDays"][1]) <7:    f.write((u"set format x \""+formatH+u"\\n%a\"    \n").encode('utf8'))
                            else:                              f.write((u"set format x \"%a\"    \n").encode('utf8'))
                       
                        if len(overWriteXFormat[1]) > 0 :
                            f.write((u"set xtics "+ overWriteXFormat[1] +" \n").encode('utf8'))            # x axis dat format on plot



                    if theType =="minute":
                        f.write((u"set timefmt \"%Y%m%d%H%M\"    \n").encode('utf8'))               # yyyymmddhhmm
                        if int(self.PLOT[nPlot]["MHDDays"][0]) >0: f.write((u"set xrange[\""+earliestDay+u"\":\""+lastDay+u"\"]\n").encode('utf8'))
   
                        if len(overWriteXFormat[0]) > 3:
                            f.write((u"set format x \""+ overWriteXFormat[0] +"\" \n").encode('utf8'))            # x axis dat format on plot
                           
                        else:
                            if   nDays ==1:                        f.write((u"set format x \""+formatH+"\" \n").encode('utf8'))
                            elif nDays ==2 or nDays== 3:            f.write((u"set format x \""+formatH+"\\n%a\"    \n").encode('utf8'))
                            else :                              f.write((u"set format x \"%a\"    \n").encode('utf8'))
                        if len(overWriteXFormat[1]) > 0 :
                            f.write((u"set xtics "+ overWriteXFormat[1] +" \n").encode('utf8'))            # x axis dat format on plot
                       


just to share the !! interesting!! challenge

Karl

Posted on
Tue Mar 20, 2018 5:40 pm
kw123 offline
User avatar
Posts: 8335
Joined: May 12, 2013
Location: Dallas, TX

Re: Change X-axis resolution

v .46 posted:
has now the following x axis format options:
1. "off" = leave # of ticks and date format to GNUPLOT or MATPLOT
2. blank, use indigoplotD suggestions
3 A) GNUPLOT: %format + ticks every xx seconds eg %H:M+2*3600 will show Hour:Min every 2 hours
3 B) MATPLOT use multiplier eg 0.1 1(default) 2 3 4 5 12 to decrease / increase # of ticks shows compared to indigoplotD suggestions


Karl

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 2 guests