def _draw_polar_axes(): global _plt viewport = _plt.kwargs['viewport'] diag = ((viewport[1]-viewport[0])**2 + (viewport[3]-viewport[2])**2)**0.5 charheight = max(0.018 * diag, 0.012) window = _plt.kwargs['window'] r_min, r_max = window[2], window[3] gr.savestate() gr.setcharheight(charheight) gr.setlinetype(gr.LINETYPE_SOLID) tick = 0.5 * gr.tick(r_min, r_max) n = int(round((r_max - r_min) / tick + 0.5)) for i in range(n+1): r = i / n if i % 2 == 0: gr.setlinecolorind(88) if i > 0: gr.drawarc(-r, r, -r, r, 0, 359) gr.settextalign(gr.TEXT_HALIGN_LEFT, gr.TEXT_VALIGN_HALF) x, y = gr.wctondc(0.05, r) gr.text(x, y, "%g" % (r_min + i * tick)) else: gr.setlinecolorind(90) gr.drawarc(-r, r, -r, r, 0, 359) for alpha in range(0, 360, 45): sinf = np.sin(np.radians(alpha+90)) cosf = np.cos(np.radians(alpha+90)) gr.polyline([sinf, 0], [cosf, 0]) gr.settextalign(gr.TEXT_HALIGN_CENTER, gr.TEXT_VALIGN_HALF) x, y = gr.wctondc(1.1 * sinf, 1.1 * cosf) gr.textext(x, y, "%d^o" % alpha) gr.restorestate()
def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None): if ismath: self._draw_mathtext(gc, x, y, s, prop, angle) else: x, y = gr.wctondc(x, y) fontsize = prop.get_size_in_points() rgba = gc.get_rgb()[:4] color = gr.inqcolorfromrgb(rgba[0], rgba[1], rgba[2]) gr.settransparency(rgba[3]) gr.setcolorrep(color, rgba[0], rgba[1], rgba[2]) gr.setcharheight(fontsize * self.nominal_fontsize) gr.settextcolorind(color) if angle != 0: gr.setcharup(-np.sin(angle * np.pi/180), np.cos(angle * np.pi/180)) else: gr.setcharup(0, 1) gr.text(x, y, s)
def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None): if ismath: self._draw_mathtext(gc, x, y, s, prop, angle) else: x, y = gr.wctondc(x, y) s = s.replace(u'\u2212', '-') fontsize = prop.get_size_in_points() rgba = gc.get_rgb()[:4] color = gr.inqcolorfromrgb(rgba[0], rgba[1], rgba[2]) gr.settransparency(rgba[3]) gr.setcolorrep(color, rgba[0], rgba[1], rgba[2]) gr.setcharheight(fontsize * 0.0013) gr.settextcolorind(color) if angle != 0: gr.setcharup(-np.sin(angle * np.pi/180), np.cos(angle * np.pi/180)) else: gr.setcharup(0, 1) gr.text(x, y, s)