I’ve created a horizontally stacked bar chart. The bar chart should have 2 Y-axis; left a number being “year”, right a float being “total”. Both year and total are part of the data set.
I’ve got no problem creating the chart with left Y-axis set to year. Also figured out how to add a second Y-axis nicely snug to the right of the bar chart. But I have no idea how to let the second Y-axis be sourced from a different column then the left Y-axis. Right now they both display the “year” column. Must be a simple fix for you graph wizards, enlighten me please.
I’ve gotten slightly further with this by using the canvas to split the Y-axis and selecting join-Y. Then in the new split Y-axis that shows up, selecting the Side to be Right.
Now it looks like I can specify Y-tick labels by selecting a column (Y tick marks = labels, Labels = selected my “totals” column). But that just shows me an empty space.
I am having trouble visualizing what you are trying to plot, but it sounds like, for each category, you are plotting two bars: year and total. If they are stacked one on top of the other, then a second Y axis for total makes no sense, as the offset of each “total” value will be different in each category, where the “total” bar will be stacked on the corresponding “year” bar (or vice versa).
You can add the “Bar” command and plot “year.” Then add a second Bar command and plot “total.” Depending on the order of the commands, you will render one in front of the other – there is probably a logical choice here. You can also use the Offset parameter to make the rearmost bar peek out from behind the frontmost bar. The key here is that both bars will be referenced to zero as the baseline. Then you can split Y and join it again and the second axis will appear on the right, with the correct, and separate, numbering once you specify the bars you want to render on the second axis.
I hope I interpreted what you are trying to do correctly. If not, it may be helpful to include a mock up of what you are trying to render. I am probably off, because plotting “year” as a dependent variable makes no sense to me (that is, it would make more sense to plot “total” on the Y axis for each “year” category on the X axis).
Yeah, sorry, intuitively obvious to only me what I am trying to do 🙂
This is part of a dog database with years in the far left column, relative litter sizes in columns 1..12, each column being subsequent litters of the dam (girl) and the far right the absolute total number of pups born that year. The plot at the bottom is only missing the absolute values I want to have plotted as the second (right) Y-axis.
So for example, the top most set of stacked bars at year 2020, I like to have the total of 132 plotted at the left. For 2019, the set of bars right below it, 293 on the left etc.
Gotcha – what you want is a label on the right end of the plot that displays the total of each year. Right now it appears that the litter data are percentages that add up to 100 (relative litter size for all litters that year), but you also want to display the absolute total on the right hand side of the plot. This would have to be an arbitrary axis, and I am not sure that you can do that in DataGraph. The “Bars” command only lets you specify labels for the categories, so you’re out of luck there.
A kludge would be to create a second set of columns that shift each successive litter amount by the cumulative total of the previous. Then you can make a set of Bar plots that are layered underneath the previous bars. This will let you specify the Total as a label on the last bar (the 12 litter bar).
For example, 1litter would be plotted as a bar. The 2litter would be plotted as a bar, but you want to plot it as:
2litter_shifted = 1litter + 2litter.
The 3litter plot would be
3litter_shifted = 2litter_shifted + 3litter
On the 12litter bar, you can enable labels and select the Total column. If the label is too close to the end of the bar, you can add a few spaces (hard spaces with the spacebar) in the “Prefix
You could also use you existing plot and make a second y bar plot behind it, where year is the category label and every bar value is 100. Then use the Total column as a label for this second plot. The second plot is just a dummy plot to be able to use the labels from Total.
Here is an example of using the Bars command to generate the plot as you currently have it, plus a second “dummy” plot using the Add Bar command (not Bars) with all of the bars equal to 100 (percent). You split Y and join Y to get the second, righthand axis and then plot the dummy bars (all 100 percent) and assign the values from Total as the labels.
You must place the dummy bars above the actual data bars in the drawing command stack so that the actual data get plotted on top.
I hope these two techniques make sense and work for you. I can also post a Dropbox link to the .dgraph file I used to make these screenshots.
Example result using the above technique.
Kirk1 year, 2 months ago dgteamModerator
Kirk – Thanks for sharing this file. For anyone that wants to open this up in DataGraph, when you download it creates a folder. You probably need to rename the folder to add “.dgraph” to the folder name. Then it can be opened in DataGraph. That is because DataGraph uses a package file format, which is really a folder that containing all the data and settings.
Another option for the use case above is to use an Extra Axis command. This command is helpful when the default axis settings don’t have the option you need, or you want to show multiple axes. It also can be used for converting axis values to different units. See the article for more information.
In your case, this can negate the need for the split and then you can specify any column to label the axis. Here is a modification of the file using the Extra axis command.
You must be logged in to reply to this topic.