
Image by Editor | ChatGPT
In our article on How To Get Started with Lux, we looked at how Lux automatically generates visualizations based on your data structure without requiring extra plotting code.
This article explores a more advanced and useful feature of Lux: expressing analysis intent. This capability allows you to guide the visualization recommendations toward specific attributes or values that interest you, making your data exploration more focused and efficient.
Understanding User Intent in Lux
User intent in Lux acts as a lens that focuses the visualization system on what matters most to your analysis. By specifying certain columns or values, you tell Lux what aspects of the data you want to examine closely, and it responds by generating tailored visualizations that highlight those elements.
When you specify intent, Lux offers two powerful recommendation types: “Enhance” (which adds variables to your intent to show relationships) and “Filter” (which shows how your variables of interest behave across different subgroups). Together, these recommendations provide a comprehensive view of your data from the perspective of your analytical interests.
Let’s see how this works with our Iris dataset example.
Setting Up Our Dataset
First, let’s import the necessary libraries and prepare our dataset:
import pandas as pd
import lux
import seaborn as sns
# Load the Iris dataset
df = sns.load_dataset('iris')
# Display the dataframe to see default recommendations
df
When you run this code in a Jupyter notebook with Lux enabled, you’ll see the familiar pandas table view with the “Toggle Pandas/Lux” button. Clicking this button without specifying any intent gives you the default recommendations we explored in the previous article.
Specifying Simple Intent
Now, let’s say we’re particularly interested in the petal_length attribute. We can express this intent by assigning it to the dataframe’s intent property:
# Specify interest in petal_length df.intent = ["petal_length"] # Display the dataframe with this intent df
When you toggle to the Lux view now, you’ll notice something different. Instead of the default Correlation, Distribution, and Occurrence tabs, Lux now shows:
- A visualization representing your specified intent (a histogram of petal_length)
- Additional recommendation tabs tailored to your intent: “Enhance” and “Filter”
Here’s what the visualization looks like with petal_length as our intent:

Image By Author
In the left panel, we can see the histogram distribution of petal_length, which clearly shows a bimodal distribution. This immediately reveals something interesting about our data: petal lengths in the Iris dataset appear to cluster into two distinct groups, suggesting natural separation between species.
On the right, under the “Enhance” tab, Lux shows relationships between petal_length and other variables. Notice how petal_length strongly correlates with both petal_width and sepal_length.
The “Filter” tab provides another interesting perspective:

Image By Author
When switching to the “Filter” tab, we can see how petal_length varies across different subgroups. The visualizations reveal that setosa species have distinctly shorter petals (clustered around 1.0-1.7 cm), while virginica species have longer petals (mostly between 4.5-6.9 cm). This explains the bimodal distribution we observed earlier.
These visualizations appear automatically, without writing a single line of plotting code, demonstrating the power of expressing intent in Lux.
Filtering by Specific Values
Lux also allows you to focus on specific values or conditions. For example, if we want to explore only setosa flowers:
# Specify interest in setosa species df.intent = ["species=setosa"] # Display the dataframe df
This tells Lux we’re interested only in the setosa species. When we toggle to the Lux view, we’ll see visualizations specifically focused on this subset of our data. Let’s examine what these visualizations reveal:

Image By Author
In the Correlation tab, we can see scatterplots displaying relationships between different measurement pairs for setosa flowers. These visualizations reveal several interesting patterns:
- Setosa flowers have consistently small petal dimensions (lengths between 1.0-1.9 cm and widths between 0.1-0.6 cm)
- There’s a positive correlation between sepal length and sepal width for setosa
- Petal dimensions show a narrow range compared to sepal dimensions
This focused view helps us understand the specific characteristics of setosa irises without the visual noise of other species.

Image By Author
Switching to the Distribution tab reveals histograms for each measurement variable within the setosa species:
- Petal width distribution is heavily skewed toward the smaller end (centered around 0.2-0.3 cm)
- Petal length shows a tight distribution centered around 1.4-1.5 cm
- Sepal length has a more normal distribution between 4.3-5.8 cm
These distributions are quite different from what we’d see in the full dataset, highlighting how filtering by a specific value helps isolate and examine patterns within subgroups. Without writing any additional code, Lux has automatically generated these visualizations based solely on our expressed intent to focus on setosa flowers.
This filtering capability becomes even more powerful when combined with attribute interests, as we’ll see in the next section.
Combining Attributes and Filters
The real power comes when combining attribute interests with filters:
# Explore petal_length for setosa species df.intent = ["petal_length", "species=setosa"] # Display the dataframe df
This tells Lux that we’re interested in analyzing petal_length specifically for the setosa species. When we toggle to the Lux view, we now see a new recommendation tab called “Generalize” alongside the familiar “Enhance” and “Filter” tabs:

Image By Author
The left panel now shows a histogram of petal_length filtered to just setosa species. On the right, the Enhance tab shows how petal_length correlates with other variables within the setosa subset, revealing relationships specific to this species.

Image By Author
The Filter tab now offers recommendations that change the species filter to alternative values. This allows for quick comparisons of how petal_length distributions differ between species. Notice how virginica and versicolor have significantly longer petals compared to setosa.

Image By Author
The new Generalize tab recommends removing filters or attributes from our intent. Here, it shows what happens if we remove the species filter, comparing our filtered view (setosa only) with the overall distribution across all species. This highlights how different setosa’s petal_length distribution is from the dataset as a whole.
By combining attributes and filters in our intent, we can direct Lux to generate targeted visualizations that answer specific analytical questions, while still exploring related perspectives through the recommendation tabs.
Benefits of Using Intent
Using intent with Lux offers several advantages over default recommendations:
- Focused exploration: Directs your attention to the attributes that matter most for your current analysis question
- Relevant insights: Generates visualizations specifically related to your areas of interest
- Efficient workflow: Reduces time spent scrolling through irrelevant visualizations
- Flexible analysis: Easily shift focus by changing your intent as your analysis questions evolve
Conclusion
User intent in Lux transforms it from a passive visualization generator to an active analysis partner that responds to your specific interests. By expressing what aspects of the data matter most to you, you can guide Lux to produce the most relevant and insightful visualizations, saving time and enhancing your understanding of the data.
There are many additional ways to specify intent in Lux, including advanced options like wildcards, axis control, and aggregation settings. To explore the full range of possibilities, you can refer to the Lux documentation on specifying intent.
