SourceForge logo
SourceForge logo
Menu

[matplotlib-devel] Small change to speed up imshow()

From: Zelakiewicz, S. \(Research\) <zel...@cr...> - 2005年04月27日 16:49:17
I routinely plot fairly large datasets (~4million points) using imshow =
but on my machine this takes about 11 secs to complete. I went through =
the code and made a couple of minor changes where the image data would =
get clipped by vmax and vmin only if the user supplied a vmax or vmin. =
The clipping is unnecessary if the user does not supply these values =
since vmax and vmin default to the max and min in the image. I also =
replaced two successive where(...) calls with a single clip(...) call =
and that seems to have helped a tiny bit as well. This change has been =
tested on 0.80 compiled with Numeric, though I can't envision how this =
would break anything. The profiler tells me that my plot time has =
decreased from 11.8 sec to 7.2 sec. Hope this helps.
Scott.
zelakiew> diff colors.py =
/local/usr/src/matplotlib-0.80/lib/matplotlib/colors.py
34c34
< zeros, asarray, sort, searchsorted, sometrue, ravel, divide, clip
---
> zeros, asarray, sort, searchsorted, sometrue, ravel, divide
554,555c554
< needs_clipping =3D True
<
---
>
562,563d560
< if vmin is None and vmax is None:
< needs_clipping =3D False
573,574c570,572
< if needs_clipping:
< val =3D clip(val,vmin, vmax)
---
>
> val =3D where(val<vmin, vmin, val)
> val =3D where(val>vmax, vmax, val)

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /