Import matplotlib.pyplot as plt import matplotlib.colors as mcolors def plotcolortable ( colors, title, sortcolors = True, emptycols = 0 ): cellwidth = 212 cellheight = 22 swatchwidth = 48 margin = 12 topmargin = 40 # Sort colors by hue, saturation, value and name. If sortcolors is True: byhsv = sorted (( tuple ( ( ( color ))), name ) for name, color in colors. Items ) names = name for hsv, name in byhsv else: names = list ( colors ) n = len ( names ) ncols = 4 - emptycols nrows = n // ncols + int ( n% ncols 0 ) width = cellwidth. 4 + 2. margin height = cellheight. nrows + margin + topmargin dpi = 72 fig, ax = ( figsize = ( width / dpi, height / dpi ), dpi = dpi ) fig. Subplotsadjust ( margin / width, margin / height, ( width - margin ) / width, ( height - topmargin ) / height ) ax.
Download Skype for Windows, Mac or Linux today. Get Skype, free messaging and video chat app. Conference calls for up to 25 people. Download Skype for Windows, Mac or Linux today. This site uses cookies for analytics, personalized content and ads. By continuing to. Shortcut Virus Remover is a portable virus remover application. It will remover your shortcut virus from your Pen drivers. DonĀ“t download it. You need to fix a pen drive, you can use it, but.
Setxlim ( 0, cellwidth. 4 ) ax. Setylim ( cellheight.
( nrows - 0.5 ), - cellheight / 2. Setvisible ( False ) ax. Setvisible ( False ) ax. Setaxisoff ax. Settitle ( title, fontsize = 24, loc = 'left', pad = 10 ) for i, name in enumerate ( names ): row = i% nrows col = i // nrows y = row. cellheight swatchstartx = cellwidth. col swatchendx = cellwidth.
col + swatchwidth textposx = cellwidth. col + swatchwidth + 7 ax. Text ( textposx, y, name, fontsize = 14, horizontalalignment = 'left', verticalalignment = 'center' ) ax. Hlines ( y, swatchstartx, swatchendx, color = colors name , linewidth = 18 ) return fig plotcolortable ( mcolors.
BASECOLORS, 'Base Colors', sortcolors = False, emptycols = 1 ) plotcolortable ( mcolors. TABLEAUCOLORS, 'Tableau Palette', sortcolors = False, emptycols = 2 ) #sphinxgallerythumbnailnumber = 3 plotcolortable ( mcolors. CSS4COLORS, 'CSS Colors' ) # Optionally plot the XKCD colors (Caution: will produce large figure) #xkcdfig = plotcolortable(mcolors.XKCDCOLORS, 'XKCD Colors') #xkcdfig.savefig('XKCDColors.png').
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2023
Categories |