def Text(s, fontSize=20, coords=(0, 0), offset=(0, 0), direction=(1, 0), color=wl.White): s = str(s) if (direction == (1, 0) or direction == ROTATE_90) and offset == (0, 0) and coords == (0, 0): # not specifying these makes Text function differently and actually work in some contexts, unfortunately t = wl.Style( wl.Text(s), color, FontSize(fontSize), ) else: t = wl.Style(wl.Text( s, coords, offset, direction, ), color, FontSize(fontSize)) if direction == ROTATE_90: t = Rotate( Rasterize( t, Background(), RasterSize(200), # ImageSize() ), wlexpr('90 Degree')) return t
def serialize_traceback(exc_type, exc_value, tb, **opts): return wl.OpenerView([ wl.Row([ safe_force_text(exc_type.__name__), " ", safe_force_text(exc_value) ]), wl.Style( wl.Column(_serialize_traceback(exc_type, exc_value, tb, **opts)), FontFamily="Courier") ], True)
def _serialize_frames(filename, function, pre_context, post_context, context_line, variables, lineno, pre_context_lineno, is_opened=False, **opts): if filename: description = wl.Row([ wl.Button( wl.Style(filename, wl.RGBColor(0.25, 0.48, 1), wl.Small, FontFamily="Courier"), wl.If(wl.FileExistsQ(filename), wl.SystemOpen(filename)), Appearance="Frameless", ), " in ", function, ]) else: description = function yield wl.OpenerView( [ description, wl.Column( iterate( (wl.Column( iterate( (_paginate(pre_context_lineno + i, l) for i, l in enumerate(pre_context)), [ wl.Item( _paginate(lineno, context_line), Background=wl.LightYellow, ) ], (_paginate(lineno + i + 1, l) for i, l in enumerate(post_context)), ), Background=[[wl.GrayLevel(0.95), wl.GrayLevel(1)]], Frame=wl.LightGray, ), ), _serialize_variables(variables), )), ], is_opened, )
def scatter(fd): color_y = [] cols = [] for xx, yy, col in zip(fd.x, fd.y, fd.item_colors): cc = wl.RGBColor(col) cols.append(cc) color_y.append( wl.Labeled( [xx, yy], wl.Style( fd.scatter_shape if fd.scatter_shape is not None else ".", cc, 40), wl.Center)) return wl.ListPlot(color_y, makefigslib.defaultPlotOptions(fd)) return weval(''' If[fd[["item_type"]]=="scatter",( If[Not2isNull[DS] && Length@x > DS, ( ds = Floor[Length@x / DS]; x = Downsample[x, ds]; y = Downsample[y, ds]; )]; ListPlot[ ( log["here1: " <> ToString@Dimensions@x <> "|" <> ToString@Dimensions@y <> "|" <> ToString@Dimensions@fd[["item_colors"]] <> "|" <> ToString@Dimensions@fd[["scatter_texts"]]]; log["here2: " <> ToString@x]; dat = If[Length@fd[["item_colors"]] > 0, MapThread[Style[{#1,#2},RGBColor[#3]]&,{x, y,fd[["item_colors"]]}] ,MapThread[{#1, #2} &, {x, y}]]; (* log["here2:" <> ToString@fd];*) If[Length@fd[["scatter_texts"]]>0,( log["here3"]; dat = If[Length@fd[["item_colors"]] > 0, MapThread[Style[Callout[#1,#2,Right,LabelStyle->RGBColor[#3]],RGBColor[#3]]&,{dat,fd[["scatter_texts"]],fd[["item_colors"]]}], MapThread[Callout[#1,#2,Right]&,{dat,fd[["scatter_texts"]]}] ]; )]; log["here4"]; dat ), defaultPlotOptions[fd], FrameLabel -> {fd[["x_label"]], fd[["y_label"]]} ] ) ''')
def Style(*args): return wl.Style(*args)