Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add labels to axis #82

Closed
RosarioAleCali opened this issue May 28, 2018 · 2 comments
Closed

Add labels to axis #82

RosarioAleCali opened this issue May 28, 2018 · 2 comments

Comments

@RosarioAleCali
Copy link

Hello everyone,
I am creating a 3D chart and I would like to add labels to the x, y, z-axis.
This is my code:

<Plot
    data={[
    {
        type: 'surface',
        x: data.x,
        y: data.y,
        z: data.z
    }
    ]}
    layout={
        {
             width: 800,
             height: 600,
             title: data.masterGraph.title,
             xaxis: {
                 title: data.masterGraph.xAxis,
                 titlefont: {
                     family: 'Courier New, monospace',
                     size: 18,
                     color: '#7f7f7f'
                 }
              },
              yaxis: {
                  title: data.masterGraph.yAxis,
                  titlefont: {
                      family: 'Courier New, monospace',
                      size: 18,
                      color: '#7f7f7f'
                   }
              },
              zaxis: {
                   title: data.masterGraph.zAxis,
                   titlefont: {
                       family: 'Courier New, monospace',
                       size: 18,
                       color: '#7f7f7f'
                     }
                   }
              }
    }
 />

where data is a JSON object. Everything seems to be working (chart title, type, and data) except for labeling the axis. Can anyone help with this?

@nicolaskruchten
Copy link
Member

The *axis that you're configuring here are for 2d axes... 3d axis configuration need to be nested under a scene key (easy to miss!). Here's the full reference for plotly.js attributes: https://plot.ly/javascript/reference/

@RosarioAleCali
Copy link
Author

@nicolaskruchten Thank you! That did it!
For everyone else who wants to look at the code, here's what I have:

layout={
                {
                    width: 800,
                    height: 600,
                    title: graphData.masterGraph.title,
                    scene: {
                        xaxis: {
                            title: graphData.masterGraph.xAxis,
                            titlefont: {
                              family: 'Courier New, monospace',
                              size: 14,
                              color: '#7f7f7f'
                            }
                        },
                        yaxis: {
                            title: graphData.masterGraph.yAxis,
                            titlefont: {
                              family: 'Courier New, monospace',
                              size: 14,
                              color: '#7f7f7f'
                            }
                        },
                        zaxis: {
                            title: graphData.masterGraph.zAxis,
                            titlefont: {
                              family: 'Courier New, monospace',
                              size: 14,
                              color: '#7f7f7f'
                            }
                        }
                    }
                }
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants