Vega / vega-lite multi-level / hierachy axes - vega

i have seen view composition techniques like facets etc.
however i am struggling to create a plot that features multiple view cells / subplots for different combinations of dimensions/groups as seen in the image for the x axis. it should be possible to not only do this for year-month-day but also for something as "country, year" and then plotting e.g. some continuous x vs. y scatter as subplot within individual cell for specific country & year.
could you provide an example json for auch a plot, so that i can have multiple groups applied for both x & y axis?
please see following vega spec for what I've tried already. I would like to add a graph on top of it, the colored boxes should be the scales.
https://vega.github.io/editor/#/url/vega/N4KABGBEAkDODGALApgWwIaQFxUQFzwAdYsB6UgN2QHN0A6agSz0QFcAjOxge1IRQyUa6SgBY6AK1jcAdpAA04KAHdGAExbYwogAw7FESCkbV8WgMx6DUQujVrGM6lv0glkWCZnoANrC0A2koQwFDeqMhakGC29o7O8lAUvqyROK4QmVDsjmpawJCOhKx4UQBO6E6RiZCoji41GAAeWgCM+lCweMiEbQC+YH3WIWHoEeXcrDJ5Nck+qVoAZr6wyDU50-mFMsWlOJBIyPAA1uzcLQNDwWChkOFpSchleIzwvgpJKQ-LfmvZuVsiiUoocTmcLoMlABdRTuNToPCYHBBLKgLKGe5RPBlZDVa6GOapfzI-GZArqKIAQQ+kFsOJkezAMlYPh8sy+Liu6LJhTy+wAQjS6cgGVSaYSHq0udybryogBhIXoemMyDU9nzB46aXc8l8qAAESVKoV4o5OClw3ReqiAFFjSLVYqNQsLX1STDSZBsZVYItuGVUIFSSEQ5lvQBPQgPDw+l6LCMKMOGY7IRP7ClW7m05WOgDSaaiwtFYZ11uTUDwUZjdJeL1kSZl4cWjGQPn1kAljabNjsDicW081G8PiiMT78UgZezZUmmxwBSHI4mUzy0-RHkYAC8HgFF153vsqM9Xr4wAB+MDGUx4MA4VQaRBTxL74eHx4nt4+C9gB8sO9XsgJhmH0UKlh61zuhAnruAgvjIMSYAomSXqYvs8DcD4AbdlkkbRlEAb9u8WZQBUVSDoc4zoQiNABhGABMOhTpB0KwoYGBlMciHIaG2ZVvh+w4vApQkZAiyzkGC6QPCiJYjikTrpAIoYWoDxojKSkMk8+QVmJjCshR8Egph2E1C2bYdhSUEyuuhisIQMlqbp6ayku76dk8Lxfj+MmsKgdBNDoAHXvgAC0vn+RGTG2eGDGDgeo5Hp5p7fpeEUBa0wVATe4UIn5dARq0z66S0UluYlH5eWeaV5ZFQU4OlgVQDFhhNPR8VvhVHmftVEDpYVAGNUV1nciNmRjdZYHukAA

There are a number of faceting examples in the Vega-Lite gallery.

Related

how to display images on matplotlib X axis instead of numbers

I have this dendrogram I've generated:
But instead of the 3,2,1,0,4 on the X axis I want to show 5 small .png images.
If this isn't possible can I show a legend where the X axis numbers correspond to an image I can display beside the graph?
Or maybe display the image above the X axis line right above the numbers?
This has been answered multiple times. Please see: Automating bar charts plotting to show country flags as ticklabels
Also, this should probably be a comment, and not an answer, but I don't have enough reputation to post comments.

Grouped errorbar with array of strings as data points

I have different measurements from two+ sensors. I want to compare the performance of each sensor for each measurement with errorbars (mean and std). I have no problems creating and formatting a standard errorbar plot for one y (sensor) and yerr per data point (measurement). But i'm trying to create a plot like this:
I can neither find the option to do this in the matplotlib documentation nor when i google it or search this site. The closest i found was this thread:
matplotlib: grouping error bars for each x-axes tick
But this solution doesn't work for me since my datapoints aren't numbers but a pandas dataframe index of strings.
So i found the solution in the Matplotlib documentation after all. Here's the link for people who might have the same question:
A bar plot with errorbars and height labels on individual bars.

Optimal display for overlapping series in a line chart

In a context of a line chart displaying time data in regular intervals where multiple series might overlap what would be the optimal way to:
A) hint the user that the chart has overlapping series?
B) give the user the capability to visualize all those series? Like spanning the series somehow?
For overlapping series in a line chart, I would keep the traditional line chart but put a label at the end of the graph with a color legend. The legend and label will help the user get information quickly.
Another version of a line chart for overlapping series can be a line area chat.
If you are not stuck on only line charts, I would suggest a bar chart. Below are some examples that you can use.
Example 1:
Example 2:
Example 3:
There are couple ways to indicate that there are overlapping series on a chart. You can increase the marker radius of one of them. The number of legend elements tells you how many series there is, too. Finally, you can distribute series on a different yAxis, with different top and height properties. Also, in styled mode, when you hover on legend item, other series opacity changes.
API Reference:
http://api.highcharts.com/highcharts/plotOptions.line.marker.radius
Examples:
http://jsfiddle.net/whsgpdyw/ - changing marker radius
http://jsfiddle.net/fuq6j4sg/ - each series on a different yAxis

Matplotlib's Figure and Axes explanation

I am really pretty new to matplotlib, though I know that it can be very powerful.
I've been reading number of tutorials and examples and it's a real hassle to understand how does matplotlib's Figure and Axes work. I am illustrating, what I am trying to understand, with the attached figure.
I know how to create a figure instance of certain size in inches. However, what bothers me is how can I create subplots and then axes, within each subplot, with relative coordinates (bottom=0,left=0,top=1,right=1) as illustrated.
So, for example I want to create a "parent" plot area (say (6in,10in)). Then, I want to create two subplot areas, each with size (3in,3in), with 1in space from the top, 2in space between the two vertical subplot areas and 1in from bottom. Then, 1in space on the left and 2in space on the write. In the same time, I would like to be able to get the coordinates of the subplot areas with respect to the main plot area.
Then, inside the first subplot area, I'd like to create 2 axis instances, with Axis 1, having coordinates with respect to Subplot Area1 (0.1,0.7,0.7,0.2) and Axes 2 (0.1,0.2,0.7,0.5). And then of course I'd like to be able to plot on these axes e.g., ax1.plot()....
If you could provide a sample code to achieve that, then I can study it.
Your help will be very much appreciated!
a subplot and an Axes object are really the same thing. There is not really a "subplot" as you describe it in matplotlib. You can just create your three Axes objects using gridspec without the need to put them in your "subplots".
There are a few different ways to create Axes instances within your figure.
fig.add_axes will create an Axes instance at the position given to it (you give it [left,bottom,width,height] in figure coordinates (i.e. 0,0 is bottom left, 1,1 is top right).
fig.add_subplot will also create an Axes instance. In this case, rather than giving it a rectangle to be created in, you give it the number of rows and columns of subplots you would like, and then the plot_number, where plot_number starts at 1, increments across rows first and has a maximum of nrows * ncols.
For example, to create the top-left Axes in a grid of 2 row and 2 columns, you could do the following:
fig.add_subplot(2,2,1)
or the shorthand
fig.add_subplot(221)
There are some more customisable ways to create Axes as well, for example gridspec and subplot2grid which allow for easy creation of many subplots of different shapes and sizes.

Reportlab LinePlot - how do I add a lineLegend...or label my lines?

I have a lineplot with 2 lines on it...they're two separate channels from the same data set. Would love to just label each one - the "labels" options are all about giving a number for each point on your plot, and that is simply not helpful.
Would love to know how to do any (really, all, but I just need to do one to be happy) of these:
plot each against its own y axis and be able to sensibly label that axis with units (and color the numbers to correspond to the data it correlates to)
put a legend on it. I can't figure out how to use lineLegend
just put any kind of (singular) label in the vicinity of the lines.