def test_boxplot_color(): source = data.barley() return ar.boxplot( source, columns=["yield"], group_by="year", color=True, width=800 // len(source["site"].unique()), ).facet(column="site")
def make_annotated_bar(source=data.barley()): bars = alt.Chart(source).mark_bar().encode(x=alt.X('sum(yield):Q', stack='zero'), y=alt.Y('variety:N'), color=alt.Color('site')) text = alt.Chart(source).mark_text(dx=-15, dy=3, color='white').encode( x=alt.X('sum(yield):Q', stack='zero'), y=alt.Y('variety:N'), detail='site:N', text=alt.Text('sum(yield):Q', format='.1f')) return bars + text
import streamlit as st import altair as alt from vega_datasets import data import pandas as pd source = data.barley() bars = alt.Chart(source, width=720, height=480).mark_bar().encode(x=alt.X('sum(yield):Q', stack='normalize'), y=alt.Y('variety:N'), color=alt.Color('site')) text = alt.Chart(source, width=720, height=480).mark_text( dx=-15, dy=3, color='white').encode(x=alt.X('sum(yield):Q', stack='normalize'), y=alt.Y('variety:N'), detail='site:N', text=alt.Text('sum(yield):Q', format='.1f')) c = bars + text source = data.stocks() stock_index = alt.Chart(source, width=720, height=180).mark_area( color="lightblue", interpolate='step-after', line=True).encode(x='date', y='price').transform_filter(alt.datum.symbol == 'GOOG') st.altair_chart(stock_index)
""" Stacked Bar Chart ----------------- This is an example of a stacked bar chart using data which contains crop yields over different regions and different years in the 1930s. """ # category: bar charts import altair as alt from vega_datasets import data barley = data.barley() alt.Chart(barley).mark_bar().encode(x='variety', y='sum(yield)', color='site')
""" Trellis Stacked Bar Chart ========================= This is an example of a horizontal stacked bar chart using data which contains crop yields over different regions and different years in the 1930s. """ # category: bar charts import altair as alt from vega_datasets import data source = data.barley() alt.Chart(source).mark_bar().encode( column='year', x='sum(yield)', y='variety', color='site' ).properties(width=250)
# Created by iiSeymour # Changed by Mandeep Singh # Changed date: 03/21/2019 # Licensce: free to use ############################################# import local_data as sample_data from flask import Flask, render_template from altair import Chart, X, Y, Axis, Data, DataFormat import pandas as pd # load a simple dataset as a pandas DataFrame from vega_datasets import data cars = data.cars() electricity = data.iowa_electricity() barley_yield = data.barley() app = Flask(__name__) ########################## # Flask routes ########################## # render index.html home page @app.route("/") def index(): return render_template('index.html') # render cars.html page @app.route("/cars")
import dash import dash_core_components as dcc import dash_bootstrap_components as dbc import dash_html_components as html from dash.dependencies import Input, Output import altair as alt import pandas as pd from vega_datasets import data app = dash.Dash(__name__, assets_folder='assets', external_stylesheets=[dbc.themes.BOOTSTRAP]) server = app.server df = data.barley() SIDEBAR_STYLE_LEFT = { "position": "fixed", "top": 0, "left": 0, "bottom": 0, "width": "300px", "padding": "2rem 1rem", "height": "100%", #"background-color": "#f8f9fa", "background-color": '#343A40', "color": 'white', "overflow": "auto" } BODY = {
def test_barchart_color(): source = data.barley() return ar.barchart(source, x="year", y="mean(yield)", color=True)