Skip to content

Commit

Permalink
Fix language as argument syntax example
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiaLingWeng authored Oct 24, 2023
1 parent 640dcac commit 261430c
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions tests/examples_methods_syntax/arrow_vector.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
"""
Arrow Vector
------------------------------
This example shows a basic vector plot use point mark ``triangle`` as shape,
This example shows a basic vector plot using point mark ``triangle`` as shape,
other shape options can be found in :ref:`Point Mark<user-guide-point-marks>`.
"""
# category: case studies
# category: line charts
import altair as alt
import numpy as np
import pandas as pd

vector1 = [0, 0, 3, -1]
vector2 = [0, 0, 2, 3]

v = pd.DataFrame([vector1, vector2], columns=['x1','y1','x2','y2'])
v = pd.DataFrame([vector1, vector2], columns=["x1","y1","x2","y2"])

# calculate the vector
v['x_'] = v['x2'] - v["x1"]
v['y_'] = v['y2'] - v["y1"]
v["x_"] = v["x2"] - v["x1"]
v["y_"] = v["y2"] - v["y1"]

# calculate the angle between current vector and the default point mark direction (0,1)
# dot product = (x_,y_) dot (0,1) = y_
v["norm"] = np.sqrt(v['x_']**2 + v['y_']**2)
v["theta"] = np.degrees(np.arccos(v['y_']/v["norm"]))
v["norm"] = np.sqrt(v["x_"]**2 + v["y_"]**2)
v["theta"] = np.degrees(np.arccos(v["y_"]/v["norm"]))

lines = alt.Chart(v).mark_line().encode(
alt.X("x1")
.title('x')
.title("x")
.scale(domain=(-4, 4)),
alt.Y("y1")
.title('y')
.title("y")
.scale(domain=(-4, 4)),
alt.X2("x2"),
alt.Y2("y2")
Expand All @@ -40,7 +40,7 @@
alt.Angle("theta")
.scale(domain=[0, 360]),
alt.SizeValue(300),
alt.ColorValue('#000000')
alt.ColorValue("#000000")
)

lines + wedge
lines + wedge

0 comments on commit 261430c

Please sign in to comment.