Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

plt title color

import matplotlib.pyplot as plt
import numpy as np
from numpy.random import randn

fig = plt.figure()
data = np.clip(randn(250,250),-1,1)
cax = plt.imshow(data, interpolation='nearest')

title_obj = plt.title('my random fig') #get the title property handler
plt.getp(title_obj)                    #print out the properties of title
plt.getp(title_obj, 'text')            #print out the 'text' property for title
plt.setp(title_obj, color='r')         #set the color of title to red

axes_obj = plt.getp(cax,'axes')                 #get the axes' property handler
ytl_obj = plt.getp(axes_obj, 'yticklabels')     #get the properties for 
                                                #  yticklabels
plt.getp(ytl_obj)                               #print out a list of properties
                                                #  for yticklabels
plt.setp(ytl_obj, color="r")                    #set the color of yticks to red

plt.setp(plt.getp(axes_obj, 'xticklabels'), color='r') #xticklabels: same

color_bar = plt.colorbar()                            #this one is a little bit
cbytick_obj = plt.getp(color_bar.ax.axes, 'yticklabels')                #tricky
plt.setp(cbytick_obj, color='r')

plt.savefig('temp.png')
plt.savefig('temp2.png', facecolor="black", edgecolor="none")
Comment

PREVIOUS NEXT
Code Example
Python :: python return 
Python :: python wsgi 
Python :: numpy and operator 
Python :: python dunder methods 
Python :: create dictionary python having hash value 
Python :: math floor python 
Python :: hide console in python build 
Python :: car python program 
Python :: DtypeWarning: Columns (7) have mixed types. Specify dtype option on import or set low_memory=False 
Python :: how to make python print 2 line text in one code 
Python :: create a list of the keys in python dictionary 
Python :: python input - how to read a number 
Python :: max of a list in python 
Python :: arithmetic operators in python 
Python :: python print array line by line 
Python :: python __new__ 
Python :: how to store object in file python 
Python :: python developer job description 
Python :: rotatelist in python 
Python :: add item to python list 
Python :: check if a number is integer or decimal in python 
Python :: grab the first letter of each string in an array python 
Python :: fastest sorting algorithm java 
Python :: py string find regex pos 
Python :: pyaudio mic stream 
Python :: how to access dictionary inside an array python 
Python :: how to remove .0 from string column with empty strings in python 
Python :: python data first column indices 
Python :: count variable in class python 
Python :: manifest.in python 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =