From: Bartosz <ma...@te...> - 2014-07-08 16:00:23
|
Hi, When improving the performance of plotting high-dimensional data using faceted scatter plots, I noticed that much of time was spent on the axis creation (even 50%!). On my machine creating 20x20 array of subplots without actually plotting anything takes about 11 seconds (for comparison plotting 5000 points on all of them takes only 0.6s!): import matplotlib matplotlib.interactive(True) import matplotlib.pyplot as plt fig, axes = plt.subplots(20,20) plt.show() Profiling shows that 50% of computation time is spent on axis/ticks creation [1], which I have to remove anyways. Is there any easy way of creating thinned axes without ticks and spines? So far I solved the problem by subclassing Axes class (see this gist [2]) and removing all spines and ticks. Running the above example gives a 10x boost in performance (from 11s to 0.9s). import thin_axes fig, axes = plt.subplots(20,20, subplot_kw=dict(projection='thin')) plt.show() Profiling results show more uniform distribution of computing time across functions (most time is spent on creating and applying transforms [3]). The thinned class seems a bit hacky. Is there any other way to create a raw Axes object without spines, ticks, labels etc., just pure canvas with appropriate transforms? Yours, Bartosz [1] profiling results of vanilla Axes: http://pbrd.co/1jlovoo [2] https://gist.github.com/btel/a6b97e50e0f26a1a5eaa [3] profiling results of thined Axes: |