CoordinatesΒΆ

We can specify coordinates as below:

chart.coordinate('type')

There are four types.

  1. rect/ cartesian (x,y):

    chart = G2.Chart(height=500, width=1000)
    chart.data(df)
    chart.interval().position('name*mpg')
    chart.coordinate('rect')
    chart.render()
    

Output:

../_images/rect_coord.png
  1. polar (r,theta):

    chart = G2.Chart(height=500, width=1000)
    chart.data(df)
    chart.interval().position('name*mpg')
    chart.coordinate('polar')
    chart.render()
    

Output:

../_images/polar_coord.png
  1. theta (theta,r):

    chart = G2.Chart(height=500, width=1000)
    chart.data(df)
    chart.interval().position('name*mpg')
    chart.coordinate('theta')
    chart.render()
    
../_images/theta_coord.png
  1. helix

    chart = G2.Chart(height=500, width=1000)
    chart.data(df)
    chart.interval().position('name*mpg')
    chart.coordinate('helix')
    chart.render()
    

Output:

../_images/helix_coord.png

There are coordinate transformation functions.

  1. transpose

    chart = G2.Chart(height=500, width=1000)
    chart.data(df)
    chart.interval().position('name*mpg')
    chart.coordinate('rect').transpose()
    chart.render()
    

Output:

../_images/coord_transpose.png
  1. reflect

    chart = G2.Chart(height=500, width=1000)
    chart.data(df)
    chart.interval().position('name*mpg')
    chart.coordinate('rect').reflect('y')
    chart.render()
    

Output:

../_images/coord_reflect.png
  1. rotate:

    chart = G2.Chart(height=500, width=1000)
    chart.data(df)
    chart.interval().position('name*mpg')
    chart.coordinate('rect').rotate(0.1)
    chart.render()
    

Output:

../_images/coord_rotate.png
  1. scale:

    chart = G2.Chart(height=500, width=1000)
    chart.data(df)
    chart.interval().position('name*mpg')
    chart.coordinate('rect').scale(0.5,0.1)
    chart.render()
    
../_images/coord_scale.png