Ask Your Question
2

Colorbar for density plots

asked 2012-10-23 20:57:25 +0200

MelvinSmith gravatar image

Hi!

I would like to know if there is a way to get a colorbar for a density plot. For contour plots this works fine with the colorbar=True option, but for density plots there doesn't seem to be such an option. Can anyone help?

Greetings, Melvin

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2012-10-23 23:20:24 +0200

Shashank gravatar image

I don't know the answer in sage but it is easy in matplotlib

import matplotlib
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import numpy as np


fig = plt.figure()
array=np.zeros((100,100))
for i in range(100):
    for j in range(100):
        array[i][j]=sin(0.1*i)*cos(0.1*j)
#norm=matplotlib.colors.Normalize(0.995,1.0)
im1 = plt.imshow(array, cmap=cm.hot, origin='lower',clip_on=True,filternorm=1)
#im1.set_norm(norm)
plt.colorbar()
plt.savefig('test.png')
edit flag offensive delete link more

Comments

Want to take a stab at #9150?

kcrisman gravatar imagekcrisman ( 2012-10-23 23:27:55 +0200 )edit

I will try.

Shashank gravatar imageShashank ( 2012-10-24 00:33:01 +0200 )edit
0

answered 2012-10-23 23:27:09 +0200

kcrisman gravatar image

updated 2012-10-23 23:27:21 +0200

This isn't built in, though Trac 9150 has been open for this for quite a while, and it probably wouldn't be too hard to put in.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-10-23 20:57:25 +0200

Seen: 749 times

Last updated: Oct 23 '12