μ°μ λμ # 185μ μ μ¬ν λ¬Έμ κ° μμ΅λλ€. κ·Έλ¬λ framealpha ν΄νΉμ μ¬κΈ°μ ν¨κ³Όμ μ΄μ§ μμ΅λλ€.
import numpy as np
import matplotlib.pyplot as plt
import mpld3
%matplotlib inline
mpld3.enable_notebook()
fig, ax = plt.subplots()
ax.scatter(np.random.randn(10), np.random.randn(10), color="red", label="data1")
ax.scatter(np.random.randn(10), np.random.randn(10), color="blue", label="data2")
ax.legend(title="Cluster", loc="best", framealpha=0)
svgμλ λ§μ»€μ λν g
μμκ° μμ§λ§ λ²λ‘μ λ λλ§λμ§ μμ΅λλ€. λ΄ μ½λμ λ¬Έμ κ° μμ΅λκΉ?
λ²κ·Έμ²λΌ 보μ λλ€. μμ μ¬νμ΄ μμΌλ©΄ κΈ°λΆλ₯Ό νμν©λλ€!
μ΄ λ¬Έμ κ° μ ν ν΄κ²°λμ§ μμλμ§ λͺ¨λ₯΄κ² μ§λ§, λ€λ₯Έ μ¬λμ΄ ν΄κ²° λ°©λ²μ΄ νμνκ³ λ²λ‘μ νΉμ λ μ΄λΈμ λν μμ λ§ νμνλ λ°μλ§ κ΄μ¬μ΄μλ κ²½μ° (μ μ΄λ κ°μΉκ°μλ) κΈκΌ΄μ μ€μ νμ΅λλ€. μμ
l = ax.legend(fancybox=0)
for i, text in enumerate(l.get_texts()):
text.set_color(colors[i])
λ λ€λ₯Έ μ§μ μ μΈ ν΄κ²° λ°©λ²μ μ°μ λμμ λ μ΄λΈμ μ κ±°ν λ€μ ax.plot()
λ‘ λΉ λ°°μ΄μ νλ‘ν
νμ¬ λ²λ‘λ₯Ό μ±μ°λ κ²μ
λλ€. κ·Έλμ λμ
fig, ax = plt.subplots()
ax.scatter(np.random.randn(10), np.random.randn(10), color="red", label="data1")
ax.scatter(np.random.randn(10), np.random.randn(10), color="blue", label="data2")
ax.legend(title="Cluster", loc="best", framealpha=0)
λ ν μμμ΄
fig, ax = plt.subplots()
ax.scatter(np.random.randn(10), np.random.randn(10), color="red")
ax.plot([], [], "o", color="red", label="data1")
ax.scatter(np.random.randn(10), np.random.randn(10), color="blue")
ax.plot([], [], "o", color="blue", label="data2")
ax.legend(title="Cluster", loc="best", framealpha=0)
λ²λ‘μλ μ»¬λ¬ λ§μ»€κ° ν¬ν¨λ©λλ€.
https://github.com/mpld3/mplexporter/pull/54 κ°μ΄ λ¬Έμ λ₯Ό ν΄κ²°ν΄μΌν©λλ€!
κ°μ₯ μ μ©ν λκΈ
λ λ€λ₯Έ μ§μ μ μΈ ν΄κ²° λ°©λ²μ μ°μ λμμ λ μ΄λΈμ μ κ±°ν λ€μ
ax.plot()
λ‘ λΉ λ°°μ΄μ νλ‘ν νμ¬ λ²λ‘λ₯Ό μ±μ°λ κ²μ λλ€. κ·Έλμ λμλ ν μμμ΄
λ²λ‘μλ μ»¬λ¬ λ§μ»€κ° ν¬ν¨λ©λλ€.