I have a 11x9 numpy matrix of float
s which I would like to visualize as a "heatmap".
Data example:
>>> print(result)
[[ 0.11686587 0.27755644 0.5768039 0.65205843 0.75033201 0.8145197
0.77202302 0.64099159 0.39442231]
[ 0.27888446 0.55511288 0.6728641 0.77335104 0.85391766 0.91633466
0.94510846 0.96901284 0.9729969 ]
[ 0.55599823 0.68171757 0.77512174 0.89287295 0.937583 0.94643648
0.96768482 0.97742364 0.97919433]
[ 0.6644533 0.76803896 0.895529 0.94510846 0.96370075 0.97211155
0.97786631 0.97919433 0.97919433]
[ 0.77290837 0.86586985 0.94953519 0.96945551 0.97698097 0.97786631
0.97786631 0.97919433 0.97919433]
[ 0.85214697 0.94245241 0.9747676 0.97653829 0.97786631 0.97786631
0.97919433 0.97919433 0.97919433]
[ 0.94200974 0.96724214 0.97565294 0.97653829 0.97609562 0.97786631
0.97919433 0.97919433 0.97919433]
[ 0.95883134 0.97255423 0.97609562 0.97742364 0.97786631 0.97786631
0.97919433 0.97919433 0.97919433]
[ 0.97166888 0.97343958 0.9747676 0.96104471 0.97830899 0.97919433
0.97919433 0.97919433 0.97919433]
[ 0.9729969 0.97565294 0.9747676 0.97255423 0.97078353 0.97919433
0.97919433 0.97919433 0.97919433]
[ 0.97078353 0.97565294 0.9747676 0.97078353 0.96989819 0.97919433
0.97919433 0.97919433 0.97919433]]
So far I've plotted it by using:
import matplotlib.pyplot as plt
plt.matshow(result)
plt.show()
The problem is that the axis are numbered from 0 to 10 and from 0 to 9. I would like to number them logarithmically from 10^-5 to 10^5 etc.
Is it somehow possible? I don't mean the axis labels but the displayed values on axis.
You can set any value of the tick labels using the function set_xticklabels and set_yticklabels . It takes a list of strings to assign to each tick. For example:
plt.set_xticklabels(["10^-5", "10^-4", "..."])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.