{"id":7922,"library":"altex","title":"Altex","description":"Altex is a Python library that provides a simplified, expressive API wrapper around Altair, designed to facilitate quick chart creation, especially within Streamlit applications. It aims to reduce the boilerplate code typically associated with Altair. The library is currently at version 0.2.0 and has an active development status, with its latest release in late 2025 focusing on dependency reduction and compatibility improvements.","status":"active","version":"0.2.0","language":"en","source_language":"en","source_url":"https://github.com/arnaudmiribel/altex","tags":["data-visualization","altair","charts","streamlit","wrapper"],"install":[{"cmd":"pip install altex","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Altex is built as a wrapper on top of Altair for chart generation.","package":"altair","optional":false},{"reason":"Commonly used for data handling with Altex charts, as shown in quickstart examples.","package":"pandas","optional":false},{"reason":"Altex offers automatic integration and is often used for displaying charts in Streamlit apps, though not strictly required for chart generation.","package":"streamlit","optional":true}],"imports":[{"note":"The primary import for accessing Altex charting functions.","symbol":"altex","correct":"import altex"},{"note":"Altex functions are typically accessed directly from the imported 'altex' module, not imported individually.","wrong":"from altex import line_chart","symbol":"line_chart","correct":"altex.line_chart(...)"}],"quickstart":{"code":"import altex\nimport pandas as pd\nimport streamlit as st # Optional, for rendering in Streamlit\n\n# Create sample data\ndata = pd.DataFrame({\n    'x': range(10),\n    'y': [i**2 for i in range(10)]\n})\n\nst.set_page_config(layout='wide') # Optional, for Streamlit layout\nst.title('Altex Quickstart Chart')\n\n# Create and display charts\nst.write(\"### Line Chart\")\naltex.line_chart(data=data, x='x', y='y', title='My Line Chart').display() # .display() for non-Streamlit environments\n\nst.write(\"### Bar Chart with Color\")\naltex.bar_chart(data=data, x='x', y='y', color='x', title='My Bar Chart').display() # .display() for non-Streamlit environments\n","lang":"python","description":"This quickstart demonstrates how to create a simple line chart and bar chart using Altex. It uses pandas for data generation and shows an example of displaying the chart directly in a Streamlit application, or by calling `.display()` which is useful in non-Streamlit environments like Jupyter notebooks. The `st.set_page_config` and `st.title`/`st.write` calls are specific to Streamlit."},"warnings":[{"fix":"Review your code for any custom Altair theme manipulations. Update to altex==0.2.0 or newer and re-test your chart rendering.","message":"The v0.2.0 release included 'Fixed Altair theme API for backward compatibility'. If you were relying on previous (potentially buggy) Altair theme behavior or directly manipulating Altair themes with Altex prior to 0.2.0, this fix might introduce behavioral changes.","severity":"breaking","affected_versions":"<0.2.0"},{"fix":"If your chart is not appearing as expected outside of Streamlit, ensure you append `.display()` to your Altex chart creation call (e.g., `altex.line_chart(...).display()`).","message":"Altex provides automatic Streamlit integration. If a chart is created within a Streamlit application context, it will attempt to render directly in Streamlit. Outside of Streamlit, Altex charting functions return an Altair Chart object, which needs an explicit `.display()` call to be rendered in environments like Jupyter notebooks.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install the library using pip: `pip install altex`","cause":"The 'altex' library is not installed in your current Python environment.","error":"ModuleNotFoundError: No module named 'altex'"},{"fix":"Ensure you have `import altex` at the top of your script and are calling functions directly from the `altex` module, e.g., `altex.line_chart(...)`.","cause":"This error often occurs if 'altex' was not imported correctly, or if you're attempting to call an Altex function on a non-Altex object, such as a dictionary, confusing it with the 'altex' module.","error":"TypeError: 'dict' object has no attribute 'line_chart' (or similar AttributeError)"},{"fix":"To display the chart, add `.display()` to your chart creation call (e.g., `altex.line_chart(data, x, y).display()`) which will typically open it in your browser. Alternatively, save it to a file: `chart.save('my_chart.html')`.","cause":"Altex charts return an Altair Chart object. In non-interactive environments or outside of Streamlit, this object needs to be explicitly rendered or saved.","error":"Chart does not display when running script outside Streamlit/Jupyter"}]}