# to just draw straight lines between the axes: t_title('Parallel Coordinates Plot', fontsize=18) Host.tick_params(axis='x', which='major', pad=7) # transform all data to be compatible with the main axis Ymins -= dys * 0.05 # add 5% padding below and above Y3 = np.random.binomial(300, 1 - category / 10, N) Y2 = np.sin(np.random.uniform(0, np.pi, N)) ** category Y1 = np.random.uniform(0, 10, N) + 7 * category import matplotlib.pyplot as pltĬategory = np.concatenate() The plot adjusts itself to the desired number of axes. When answering a related question, I worked out a version using only one subplot (so it can be easily fit together with other plots) and optionally using cubic bezier curves to connect the points. It isn't quite as nice as the reference image from Wikipedia, but it is passable if all you have is Matplotlib and you need multi-dimensional plots. Here is an example of what comes out of the above code when plotting Fisher's Iris data. Parallel_coordinates(data, style=colors).show() Labels = ĭata = + random.uniform(0., 1.)*scaleĭata.extend( + random.uniform(0., 1.)*scaleįor x in xrange(5)] for y in xrange(30)]) # Move the final axis' ticks to the right-hand sideĪxx.t_major_locator(ticker.FixedLocator(, x])) Nds = ) /įor dimension, (axx,xx) in enumerate(zip(axes, x)):Īxx.t_major_locator(ticker.FixedLocator()) #!/usr/bin/pythonĭef parallel_coordinates(data_sets, style=None):įig, axes = plt.subplots(1, dims-1, sharey=False) This solution isn't as good as a built-in solution since you have odd mouse behavior and I'm faking the data ranges through labels, but until Matplotlib adds a built-in solution, it's acceptable. The lines are random within ranges that cause clustering of lines a behavior I wanted to verify. The example in _main_ grabs random numbers for each axis in two sets of 30 lines. Each data set is considered a set of points where each point lies on a different axis. The function works by accepting an iterable of data sets. I then go back and apply labels to each tick-mark that give the correct value at that intercept. I accomplished this by normalizing the data at each axis point and making the axes have a range of 0 to 1. ![]() Following the plot style of the example I posted in the original question above, each axis gets its own scale. If there is no built-in-type, is it possible to build a parallel coordinates plot using standard features of Matplotlib?īased on the answer provided by Zhenya below, I developed the following generalization that supports an arbitrary number of axes.Is there a built-in parallel coordinates plot in Matplotlib? I certainly don't see one in the gallery.Several plotting packages provide parallel coordinates plots, such as Matlab, R, VTK type 1 and VTK type 2, but I don't see how to create one using Matplotlib. Fortunately, parallel coordinates plots provide a mechanism for viewing results with higher dimensions. Dimensions above four, though, become increasingly difficult to display. Even with four dimensional data, we can often find a way to display the data. Two and three dimensional data can be viewed relatively straight-forwardly using traditional plot types.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |