def set_title(self, label, fontname=None, fontsize=14, bold=True, color='black'): """ Add a centered title to the figure. :param label: (*string*) Title label string. :param fontname: (*string*) Font name. Default is ``Arial`` . :param fontsize: (*int*) Font size. Default is ``14`` . :param bold: (*boolean*) Is bold font or not. Default is ``True`` . :param color: (*color*) Title string color. Default is ``black`` . """ exfont = False if fontname is None: fontname = 'Arial' else: exfont = True if bold: font = Font(fontname, Font.BOLD, fontsize) else: font = Font(fontname, Font.PLAIN, fontsize) c = plotutil.getcolor(color) ctitle = ChartText(label, font) ctitle.setUseExternalFont(exfont) ctitle.setColor(c) self.getChart().setTitle(ctitle) return ctitle
def text(x, y, s, **kwargs): """ Add text to the axes. Add text in string *s* to axis at location *x* , *y* , data coordinates. :param x: (*float*) Data x coordinate. :param y: (*float*) Data y coordinate. :param s: (*string*) Text. :param fontname: (*string*) Font name. Default is ``Arial`` . :param fontsize: (*int*) Font size. Default is ``14`` . :param bold: (*boolean*) Is bold font or not. Default is ``False`` . :param color: (*color*) Tick label string color. Default is ``black`` . :param coordinates=['axes'|'figure'|'data'|'inches']: (*string*) Coordinate system and units for *X, Y*. 'axes' and 'figure' are normalized coordinate system with 0,0 in the lower left and 1,1 in the upper right, 'data' are the axes data coordinates (Default value); 'inches' is position in the figure in inches, with 0,0 at the lower left corner. :returns: (*ChartText*) text. """ fontname = kwargs.pop('fontname', None) exfont = False if fontname is None: fontname = 'Arial' else: exfont = True fontsize = kwargs.pop('fontsize', 14) bold = kwargs.pop('bold', False) color = kwargs.pop('color', 'black') if bold: font = Font(fontname, Font.BOLD, fontsize) else: font = Font(fontname, Font.PLAIN, fontsize) c = getcolor(color) text = ChartText(s, font) text.setUseExternalFont(exfont) text.setColor(c) text.setX(x) text.setY(y) xalign = kwargs.pop('xalign', None) if not xalign is None: text.setXAlign(xalign) yalign = kwargs.pop('yalign', None) if not yalign is None: text.setYAlign(yalign) bbox = kwargs.pop('bbox', None) if not bbox is None: fill = bbox.pop('fill', None) if not fill is None: text.setFill(fill) facecolor = bbox.pop('facecolor', None) if not facecolor is None: facecolor = getcolor(facecolor) text.setFill(True) text.setBackground(facecolor) edge = bbox.pop('edge', None) if not edge is None: text.setDrawNeatline(edge) edgecolor = bbox.pop('edgecolor', None) if not edgecolor is None: edgecolor = getcolor(edgecolor) text.setNeatlineColor(edgecolor) text.setDrawNeatline(True) linewidth = bbox.pop('linewidth', None) if not linewidth is None: text.setNeatlineSize(linewidth) text.setDrawNeatline(True) gap = bbox.pop('gap', None) if not gap is None: text.setGap(gap) rotation = kwargs.pop('rotation', None) if not rotation is None: text.setAngle(rotation) coordinates = kwargs.pop('coordinates', 'data') text.setCoordinates(coordinates) return text