ticks perpendicular to line on plot command

Welcome to our Forums Technical Support Support Desk ticks perpendicular to line on plot command

Viewing 10 posts - 1 through 10 (of 12 total)
  • Author
    Posts
  • #6997
    scgc
    Participant

      Like the title said…is there a way to add little tick marks or markers that are perpendicular lines, as in the figure below?

      ticks-ex-dg

      I made this figure using a different plotting program, and then had to spend a lot of time in Illustrator manually positioning and rotating each tick mark. It would be great if I could do this automatically in Datagraph.

      #7029
      dgteam
      Moderator

        Love to help you avoid anything tedious!  There is not an entirely automatic way, but you can do this programmatically using the Connect command.

        We posted  an example to show how, with some calculations in the data table to determine the beginning and end locations.  See the on-line examples for the file with instructions.  The nice thing is that if your data changes the tick mark locations and angles will also update automatically.

        Does this help?  Other questions?

        PlotTangent

        #7032
        scgc
        Participant

          Thanks, this looks helpful! I’ll work through it and see what I can do. I see the connect command also contains a masking option…excellent, since my curves are drawn with ~100 data points but I only want to add ticks at certain locations.

          #7034
          scgc
          Participant

            Hey actually, small nitpick: The online example refers to tick marks “tangent” to the line, but should say perpendicular.

            #7035
            dgteam
            Moderator

              Great catch!  Thanks for pointing that out.

              We created this template based on another file that was drawing lines tangent to a function – looks like that terminology hung around.  We will correct that.

              #7036
              dgteam
              Moderator

                The corrected file was just uploaded.  Also noticed one screenshot in the instructions that was another hold over, but let us know if any of the instructions are not clear.

                FYI – You can also copy and paste these objects into your own file, no need to recreate everything.  The equations will need a column called x and y to work, but you can always use a Redirect column to give an alias to your existing data.  The only column that requires you to specifically pick the columns using menus is the Plot action column that estimates the slope.

                #7038
                scgc
                Participant

                  Okay…so I’m still having some trouble. I think it’s related to the extreme difference in scale in my x and y axes, but playing with the aspect ratio doesn’t fix it. Here’s a pair of screenshots I took after pasting my own data directly into the x and y columns in the online example…no changes to any expression columns.

                  dg ticks A

                  dg ticks B

                  With my dataset, the ticks are always vertical. Adjusting the aspect ratio value doesn’t cause them to rotate, but at small fractional values, the length decreases (as in the screenshots I uploaded). And it might be hard to tell, but the length of the ticks increases from left to right in the second picture.

                  Any suggestions for making this work then the axes have such extreme scale differences, if that’s even what my issue is here?

                  #7039
                  dgteam
                  Moderator

                    The small values for the slope was the issue.  We had only tested the file for data with similar ranges.  Sorry about that!

                    We revised the template/calculations to add scaling factors.  See the instructions in the file for the details.  The new file is now on-line.

                    This should be more robust for different data ranges.   Note the graph below with different x and y scales.  The basic approach is the same but the new file allows you to choose the data with redirect columns.

                    If you want to copy these calculations into your file, copy and paste the data group first, then copy and paste all the variables.

                    Let us know if this solves the problem for you.

                    Draw-Tangent-tick marks scale

                    #7040
                    scgc
                    Participant

                      This is great…works well and is very easy to use. Thanks so much!

                      #7042
                      scgc
                      Participant

                        So…the updated solution works great when both x and y are linear, but it gets weird when I start using log-scale axes. This makes sense because the ticks are all lines plotted using calculated x,y coordinates.

                        dg ticks semilog

                        The only solution I can think of would be to replace the pick_x and pick_y redirect columns with expression columns that calculate the logs of whatever my data columns are, and plot the data using linear x and y axes. But I think this would also require me to add new columns to every dataset I’m working with, every time I make a new graph with a log-scale axis. That can get to be an awful lot of work with all the different groups of data I’m working with.

                        Perhaps there is a way to calculate x,y coordinates for the connect commands to maintain tick length and perpendicularity on a log or semi-log plot…but I’m not sure I’m mathematically-inclined enough to figure that out.

                      Viewing 10 posts - 1 through 10 (of 12 total)
                      • You must be logged in to reply to this topic.

                      Welcome to our Forums Technical Support Support Desk ticks perpendicular to line on plot command