I'm creating a map in CartoDB. I have roughly 18 categories, but each of those has a sub-category, which is 'yes' or 'no'.

Currently I am displaying the 18 categories in two different layers to get around the 10 category max limit.

How can I display all of these categories in as few layers as possible?

2 Answers 2


You can show as many categories as you want in one layer, but you'll have to do some custom coding. My approach would be:

  1. Start with as many categories as you can using the Category Visualization Wizard (which I assume you're already doing).
  2. Click the CSS icon on the sidebar. This takes you to the CartoCSS editor. Here you can copy and modify the style rules from other categories in order to style the rest of the categories. For example, I have an earthquakes layer categorized by magnitude. My CartoCSS looks like:

    #earthquakes[mag=5] {
        marker-fill: #A6CEE3;
    #earthquakes[mag=5.1] {
        marker-fill: #1F78B4;

    I would copy and paste three of these lines, change the condition (eg, from mag=5.1 to mag=5.2), and set the color to a new one.

  3. Finally, you have to edit the legend. If you open the legend editor and click the </> link near the top, you can use a similar technique to the above (except in HTML instead of CartoCSS) to add your new categories to the legend.
  • When I tried this, still only 10 categories would be visible. It would lump all of the others into an 'other' category! Jul 1, 2014 at 1:48
  • Right, you have to add the categories manually in the legend's HTML as I say in (3), otherwise you're not going to see them in the legend. Jul 1, 2014 at 3:55
  • Yeah I do this. Only 10 showed in the map. Jul 1, 2014 at 4:06
  • Are you certain you are setting both the condition and color for each category in your CartoCSS? There is no limitation on how many colors and styles you have if you're using CartoCSS, so it's almost certainly a code issue. Jul 1, 2014 at 4:43
  • I'm using images rather than colors Jul 1, 2014 at 5:13

I had a similar problem. You need to make changes in two different places -- CartoCSS and the custom HTML in the Legend tab.

What happened for me was that editing the CartoCSS changed the colors on the map but not the legend. But you can manually change the legend in html as well. I copied the code from CartoCSS so that I could copy the correct hex color codes (which you basically have to do manually). Also gives you the ability have more control over the labels in your legend while you're at it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.