0

I saw this example on how to create a parallel coordinate plot: Parallel Coordinates:

enter image description here

This creates a nice Parallel Coordinates figure, but I would like to add this plot to an already existing figure in a subplot (there should be another plot next to it in the same plot).

For the already existing figure, the figure and axes are defined as:

fig = plt.figure(figsize=plt.figaspect(2.))
ax =  fig.add_subplot(1,2,1)

For the Parallel Coordinates, they suggest:

fig, axes = plt.subplots(1, dims-1, sharey=False)

How can I reconcile both initializations of the figure and the ax(es)?

Community
  • 1
  • 1
Jan
  • 111
  • 2
  • 7
  • You are saying you already has a figure `fig` and there are already some plots in that figure and now you want the parallel coordinates plot to be overlaid in subplot #1, right? – CT Zhu Jan 10 '14 at 02:26
  • That is exactly what I want, yes :-) – Jan Jan 10 '14 at 07:09

1 Answers1

1

One option is to create all the axes using subplots then just shift the location of the one that you don't want to have wspace=0 as is done for the Parallel Coordinate plots:

import matplotlib.pylab as plt

dims = 4
fig, axes = plt.subplots(1, dims-1 + 1, sharey=False)

plt.subplots_adjust(wspace=0)

ax1 = axes[0]
pos = ax1.get_position()
ax1.set_position(pos.translated(tx = -0.1,ty=0))

enter image description here

I have added 1 to the number of columns creates (leaving it explicitly -1+1) and set wspace=0 which draws all the plots adjacent to one another with no space inbetween. Take the left most axes and get the position which is a Bbox. This is nice as it gives you the ability to translate it by tx=-0.1 separating your existing figure.

Greg
  • 11,654
  • 3
  • 44
  • 50
  • This already looks great! Now, for some applications the plot next to the Parallel Coordinates should become two plots, preferably on top of each other. And it would be nice if the separate plot has the same width as the complete Parallel Coordinates plot. Are those things possible? – Jan Jan 10 '14 at 14:23
  • Yes I suggest you have a read of [this](http://matplotlib.org/users/gridspec.html). – Greg Jan 10 '14 at 15:49
  • Hi @Greg can you help solve the issues with these parallel coordinates - https://stackoverflow.com/questions/49329600/d3-v4-parallel-coordinates-selection-of-paths-with-d3-v4-brushes or https://stackoverflow.com/questions/49334965/syntagmatic-nutrient-parallel-coordinate-chart-highlight-data-row . It would be of great help. Thanks in advance. – Harshit Laddha Mar 17 '18 at 10:46