from lets_plot import *
import pandas as pd
LetsPlot.setup_html()
df = {
'x' : [1, 1, 2, 2, 1.5],
'y' : [1, 2, 1, 2, 1.5],
'text': ["bottom-left", "top-left", "bottom-right", "top-right", "center"]
}
w, h = 400, 250
p = ggplot(df, aes('x', 'y')) + geom_point(size=3) + ggsize(w,h) + theme_classic()
p + geom_text(aes(label = 'text'), size=8, hjust = 'inward', angle=0)
angles = [0,45,90,135,180,225,270,315]
def justificationWithAngles(hjust=None, vjust=None):
bunch = GGBunch()
for i in range(len(angles)):
angle = angles[i]
row = int(i / 2)
column = i % 2
pp = p + geom_text(aes(label = 'text'), size=8, hjust = hjust, vjust = vjust, angle=angle) +\
ggtitle("Angle: " + str(angle))
bunch.add_plot(pp, column * w, row * h, w, h)
return bunch.show()
justificationWithAngles(hjust='inward')
justificationWithAngles(hjust='outward')
justificationWithAngles(vjust='inward')
justificationWithAngles(vjust='outward')