3D Histogram / bar chartSorting according to more than one key in pgfplotstable3d histogram without external programspgfplots using strings *from data table* as x axis labels in bar chartBar chart from CSV file with adjustable bar widthHow to draw a bar chart from multiple measurements with mean and varianceSegmented bar chart under tikz plotCombining line chart data with bar plotInsert space after each second barHow to plot histogram from a tab separated csv file containing tabular list of ordered tuples?Combine boxplot and histogram in one diagram (PGF/TikZ)pgfplots Histogram with Automatically Calculated Percentage BinsHistogram in pgfplots: Count the total number of data values
How do we explain the use of a software on a math paper?
Is it wise to pay off mortgage with 401k?
Why was Harry at the Weasleys' at the beginning of Goblet of Fire but at the Dursleys' after?
Bash - Execute two commands and get exit status 1 if first fails
What does it mean for a program to be 32 or 64 bit?
Do seaplanes need to get clearance for takeoff?
Will this series of events work to drown the Tarrasque?
Existence of a model of ZFC in which the natural numbers are really the natural numbers
Does a windmilling propeller create more drag than a stopped propeller in an engine out scenario?
List of lists elementwise greater/smaller than
How did Jean Parisot de Valette, 49th Grand Master of the Order of Malta, die?
How to tease a romance without a cat and mouse chase?
tikz: 5 squares on a row, roman numbered 1 -> 5
why "American-born", not "America-born"?
Connecting circles clockwise in TikZ
Why is this python script running in background consuming 100 % CPU?
If you attack a Tarrasque while swallowed, what AC do you need to beat to hit it?
What should I wear to go and sign an employment contract?
What to call a small, open stone or cement reservoir that supplies fresh water from a spring or other natural source?
What causes a person to remain in this world as a ghost?
Difference in 1 user doing 1000 iterations and 1000 users doing 1 iteration in Load testing
On a piano, are the effects of holding notes and the sustain pedal the same for a single chord?
Warped chessboard
Why did Nick Fury not hesitate in blowing up the plane he thought was carrying a nuke?
3D Histogram / bar chart
Sorting according to more than one key in pgfplotstable3d histogram without external programspgfplots using strings *from data table* as x axis labels in bar chartBar chart from CSV file with adjustable bar widthHow to draw a bar chart from multiple measurements with mean and varianceSegmented bar chart under tikz plotCombining line chart data with bar plotInsert space after each second barHow to plot histogram from a tab separated csv file containing tabular list of ordered tuples?Combine boxplot and histogram in one diagram (PGF/TikZ)pgfplots Histogram with Automatically Calculated Percentage BinsHistogram in pgfplots: Count the total number of data values
Hello fellows and folks!
I wanted to know if it is possible to plot a 3D histogram like these:
The file is a .csv one with 100K rows/tuples. My idea is to plot users (x-axis), movies(y-axis) and ratings (z-axis). For the first 10 rows or something like that.
Is it possible to draw?
This is how the structure of the file looks:
UserID, MovieID, Rating
1,5,5
2,4,3
3,4,2
4,2,2
5,3,5
6,1,5
7,2,2
8,2,3
9,1,4
1,2,4
1,3,4
2,2,3
2,3,5
2,5,4
3,1,5
3,2,2
3,5,3
4,3,3
4,4,1
4,5,2
5,1,4
5,4,4
5,5,5
6,2,3
6,4,3
6,5,5
7,1,3
7,3,3
7,4,2
8,1,5
8,3,4
8,5,5
9,2,2
9,3,5
9,4,4
10,3,5
10,4,3
10,5,4
bar-chart tikz-3dplot histogram
add a comment |
Hello fellows and folks!
I wanted to know if it is possible to plot a 3D histogram like these:
The file is a .csv one with 100K rows/tuples. My idea is to plot users (x-axis), movies(y-axis) and ratings (z-axis). For the first 10 rows or something like that.
Is it possible to draw?
This is how the structure of the file looks:
UserID, MovieID, Rating
1,5,5
2,4,3
3,4,2
4,2,2
5,3,5
6,1,5
7,2,2
8,2,3
9,1,4
1,2,4
1,3,4
2,2,3
2,3,5
2,5,4
3,1,5
3,2,2
3,5,3
4,3,3
4,4,1
4,5,2
5,1,4
5,4,4
5,5,5
6,2,3
6,4,3
6,5,5
7,1,3
7,3,3
7,4,2
8,1,5
8,3,4
8,5,5
9,2,2
9,3,5
9,4,4
10,3,5
10,4,3
10,5,4
bar-chart tikz-3dplot histogram
Yes, it is, see here. Do you have the data in another form than a screen shot but just text?
– marmot
2 hours ago
Yes, I do! I will edit the post with the text data.
– naveganteX
2 hours ago
add a comment |
Hello fellows and folks!
I wanted to know if it is possible to plot a 3D histogram like these:
The file is a .csv one with 100K rows/tuples. My idea is to plot users (x-axis), movies(y-axis) and ratings (z-axis). For the first 10 rows or something like that.
Is it possible to draw?
This is how the structure of the file looks:
UserID, MovieID, Rating
1,5,5
2,4,3
3,4,2
4,2,2
5,3,5
6,1,5
7,2,2
8,2,3
9,1,4
1,2,4
1,3,4
2,2,3
2,3,5
2,5,4
3,1,5
3,2,2
3,5,3
4,3,3
4,4,1
4,5,2
5,1,4
5,4,4
5,5,5
6,2,3
6,4,3
6,5,5
7,1,3
7,3,3
7,4,2
8,1,5
8,3,4
8,5,5
9,2,2
9,3,5
9,4,4
10,3,5
10,4,3
10,5,4
bar-chart tikz-3dplot histogram
Hello fellows and folks!
I wanted to know if it is possible to plot a 3D histogram like these:
The file is a .csv one with 100K rows/tuples. My idea is to plot users (x-axis), movies(y-axis) and ratings (z-axis). For the first 10 rows or something like that.
Is it possible to draw?
This is how the structure of the file looks:
UserID, MovieID, Rating
1,5,5
2,4,3
3,4,2
4,2,2
5,3,5
6,1,5
7,2,2
8,2,3
9,1,4
1,2,4
1,3,4
2,2,3
2,3,5
2,5,4
3,1,5
3,2,2
3,5,3
4,3,3
4,4,1
4,5,2
5,1,4
5,4,4
5,5,5
6,2,3
6,4,3
6,5,5
7,1,3
7,3,3
7,4,2
8,1,5
8,3,4
8,5,5
9,2,2
9,3,5
9,4,4
10,3,5
10,4,3
10,5,4
bar-chart tikz-3dplot histogram
bar-chart tikz-3dplot histogram
edited 2 hours ago
naveganteX
asked 2 hours ago
naveganteXnaveganteX
1927
1927
Yes, it is, see here. Do you have the data in another form than a screen shot but just text?
– marmot
2 hours ago
Yes, I do! I will edit the post with the text data.
– naveganteX
2 hours ago
add a comment |
Yes, it is, see here. Do you have the data in another form than a screen shot but just text?
– marmot
2 hours ago
Yes, I do! I will edit the post with the text data.
– naveganteX
2 hours ago
Yes, it is, see here. Do you have the data in another form than a screen shot but just text?
– marmot
2 hours ago
Yes, it is, see here. Do you have the data in another form than a screen shot but just text?
– marmot
2 hours ago
Yes, I do! I will edit the post with the text data.
– naveganteX
2 hours ago
Yes, I do! I will edit the post with the text data.
– naveganteX
2 hours ago
add a comment |
1 Answer
1
active
oldest
votes
Here is a proposal. You need to compile twice.
documentclass[tikz,border=3.14pt]standalone
usetikzlibrarycalc
usepackagepgfplots
usepackagepgfplotstable
pgfplotssetcompat=1.16
% from https://tex.stackexchange.com/a/102770/121799
defpgfplotsinvokeiflessthan#1#2#3#4%
pgfkeysvalueof/pgfplots/iflessthan/.@cmd#1#2#3#4pgfeov
%
defpgfplotsmulticmpthree#1#2#3#4#5#6do#7#8%
pgfplotssetfloat <%
pgfplotsinvokeiflessthan#1#4%
% first key <:
#7%
%
pgfplotsinvokeiflessthan#4#1%
% first key >:
#8%
%
% first key ==:
pgfplotssetfloat <%
pgfplotsinvokeiflessthan#2#5%
% second key <
#7%
%
pgfplotsinvokeiflessthan#5#2%
% second key >
#8%
%
% second key ==
pgfplotssetfloat <%
pgfplotsinvokeiflessthan#3#6%
% third key <
#7%
%
% third key >=
#8%
%
%
%
%
%
%
begindocument
ifdefinedgconv
else
pgfmathsetmacrogconv0.1
fi
pgfplotstableread[col sep=comma,header=true]%
y,x,myvalue
1,5,5
2,4,3
3,4,2
4,2,2
5,3,5
6,1,5
7,2,2
8,2,3
9,1,4
1,2,4
1,3,4
2,2,3
2,3,5
2,5,4
3,1,5
3,2,2
3,5,3
4,3,3
4,4,1
4,5,2
5,1,4
5,4,4
5,5,5
6,2,3
6,4,3
6,5,5
7,1,3
7,3,3
7,4,2
8,1,5
8,3,4
8,5,5
9,2,2
9,3,5
9,4,4
10,3,5
10,4,3
10,5,4
datatable
%
%pgfplotstablesort[col sep=comma,header=true]resulttabledatatable
pgfplotstablesort[create on use/sortkey/.style=
create col/assign/.code=%
edefentrythisrowxthisrowythisrowmyvalue%
pgfkeyslet/pgfplots/table/create col/next contententry
,
sort key=sortkey,
sort cmp=%
iflessthan/.code args=#1#2#3#4%
edeftemp#1#2%
expandafterpgfplotsmulticmpthreetempdo#3#4%
,
,
sort,
columns/Mtx/.style=string type,
columns/Kind/.style=string type,]resulttabledatatable
begintikzpicture%[x=(0.866cm,-0.5cm),y=(0.866cm,0.5cm),z=(0cm,1 cm)]
pgfplotssetset layers
beginaxis[% from section 4.6.4 of the pgfplotsmanual
view=12040,
width=320pt,
height=280pt,
z buffer=none,
xmin=-1,xmax=5,
ymin=0,ymax=9,
zmin=0,zmax=10,
enlargelimits=upper,
ztick=0,5,10,
zticklabels=0,2.5,5, % here one has to "cheat"
% meaning that one has to put labels which are the actual value
% divided by 2. This is because the bars will be centered at these
% values
xtick=data,
extra tick style=grid=major,
ytick=data,
grid=minor,
xlabel=$x$,
ylabel=$y$,
zlabel=$z$,
minor tick num=1,
point meta=explicit,
colormap name=viridis,
scatter/use mapped color=
draw=mapped color,fill=mapped color!70,
execute at begin plot=
]
path let p1=($(axis cs:0,0,1)-(axis cs:0,0,0)$) in
pgfextrapgfmathsetmacroconv2*y1
ifxgconvconv
else
xdefgconvconv
typeoutPleasespace recompilespace thespace file!
fi
;
path let p1=($(axis cs:1,0,0)-(axis cs:0,0,0)$) in
pgfextrapgfmathsetmacroconvxveclen(x1,y1)
typeoutOnespace unitspace inspace xspace
directionspace isspaceconvx pt
;
path let p1=($(axis cs:0,1,0)-(axis cs:0,0,0)$) in
pgfextrapgfmathsetmacroconvyveclen(x1,y1)
typeoutOnespace unitspace inspace yspace
directionspace isspaceconvy pt
;
addplot3 [visualization depends on=
gconv*z as myz, % you may have to recompile to get the prefactor right
scatter/@pre marker code/.append style=/pgfplots/cube/size z=myz,%
scatter/@pre marker code/.append style=/pgfplots/cube/size x=11.66135pt,%
scatter/@pre marker code/.append style=/pgfplots/cube/size y=9.10493pt,%
scatter,only marks,
mark=cube*,mark size=5,opacity=1]
table[x expr=thisrowx,y expr=thisrowy,z
expr=1*thisrowmyvalue,
meta expr=-1*thisrowx
] resulttable;
endaxis
makeatletter
immediatewrite@mainauxxdefstringgconvgconvrelax
makeatother
endtikzpicture
enddocument
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f491565%2f3d-histogram-bar-chart%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here is a proposal. You need to compile twice.
documentclass[tikz,border=3.14pt]standalone
usetikzlibrarycalc
usepackagepgfplots
usepackagepgfplotstable
pgfplotssetcompat=1.16
% from https://tex.stackexchange.com/a/102770/121799
defpgfplotsinvokeiflessthan#1#2#3#4%
pgfkeysvalueof/pgfplots/iflessthan/.@cmd#1#2#3#4pgfeov
%
defpgfplotsmulticmpthree#1#2#3#4#5#6do#7#8%
pgfplotssetfloat <%
pgfplotsinvokeiflessthan#1#4%
% first key <:
#7%
%
pgfplotsinvokeiflessthan#4#1%
% first key >:
#8%
%
% first key ==:
pgfplotssetfloat <%
pgfplotsinvokeiflessthan#2#5%
% second key <
#7%
%
pgfplotsinvokeiflessthan#5#2%
% second key >
#8%
%
% second key ==
pgfplotssetfloat <%
pgfplotsinvokeiflessthan#3#6%
% third key <
#7%
%
% third key >=
#8%
%
%
%
%
%
%
begindocument
ifdefinedgconv
else
pgfmathsetmacrogconv0.1
fi
pgfplotstableread[col sep=comma,header=true]%
y,x,myvalue
1,5,5
2,4,3
3,4,2
4,2,2
5,3,5
6,1,5
7,2,2
8,2,3
9,1,4
1,2,4
1,3,4
2,2,3
2,3,5
2,5,4
3,1,5
3,2,2
3,5,3
4,3,3
4,4,1
4,5,2
5,1,4
5,4,4
5,5,5
6,2,3
6,4,3
6,5,5
7,1,3
7,3,3
7,4,2
8,1,5
8,3,4
8,5,5
9,2,2
9,3,5
9,4,4
10,3,5
10,4,3
10,5,4
datatable
%
%pgfplotstablesort[col sep=comma,header=true]resulttabledatatable
pgfplotstablesort[create on use/sortkey/.style=
create col/assign/.code=%
edefentrythisrowxthisrowythisrowmyvalue%
pgfkeyslet/pgfplots/table/create col/next contententry
,
sort key=sortkey,
sort cmp=%
iflessthan/.code args=#1#2#3#4%
edeftemp#1#2%
expandafterpgfplotsmulticmpthreetempdo#3#4%
,
,
sort,
columns/Mtx/.style=string type,
columns/Kind/.style=string type,]resulttabledatatable
begintikzpicture%[x=(0.866cm,-0.5cm),y=(0.866cm,0.5cm),z=(0cm,1 cm)]
pgfplotssetset layers
beginaxis[% from section 4.6.4 of the pgfplotsmanual
view=12040,
width=320pt,
height=280pt,
z buffer=none,
xmin=-1,xmax=5,
ymin=0,ymax=9,
zmin=0,zmax=10,
enlargelimits=upper,
ztick=0,5,10,
zticklabels=0,2.5,5, % here one has to "cheat"
% meaning that one has to put labels which are the actual value
% divided by 2. This is because the bars will be centered at these
% values
xtick=data,
extra tick style=grid=major,
ytick=data,
grid=minor,
xlabel=$x$,
ylabel=$y$,
zlabel=$z$,
minor tick num=1,
point meta=explicit,
colormap name=viridis,
scatter/use mapped color=
draw=mapped color,fill=mapped color!70,
execute at begin plot=
]
path let p1=($(axis cs:0,0,1)-(axis cs:0,0,0)$) in
pgfextrapgfmathsetmacroconv2*y1
ifxgconvconv
else
xdefgconvconv
typeoutPleasespace recompilespace thespace file!
fi
;
path let p1=($(axis cs:1,0,0)-(axis cs:0,0,0)$) in
pgfextrapgfmathsetmacroconvxveclen(x1,y1)
typeoutOnespace unitspace inspace xspace
directionspace isspaceconvx pt
;
path let p1=($(axis cs:0,1,0)-(axis cs:0,0,0)$) in
pgfextrapgfmathsetmacroconvyveclen(x1,y1)
typeoutOnespace unitspace inspace yspace
directionspace isspaceconvy pt
;
addplot3 [visualization depends on=
gconv*z as myz, % you may have to recompile to get the prefactor right
scatter/@pre marker code/.append style=/pgfplots/cube/size z=myz,%
scatter/@pre marker code/.append style=/pgfplots/cube/size x=11.66135pt,%
scatter/@pre marker code/.append style=/pgfplots/cube/size y=9.10493pt,%
scatter,only marks,
mark=cube*,mark size=5,opacity=1]
table[x expr=thisrowx,y expr=thisrowy,z
expr=1*thisrowmyvalue,
meta expr=-1*thisrowx
] resulttable;
endaxis
makeatletter
immediatewrite@mainauxxdefstringgconvgconvrelax
makeatother
endtikzpicture
enddocument
add a comment |
Here is a proposal. You need to compile twice.
documentclass[tikz,border=3.14pt]standalone
usetikzlibrarycalc
usepackagepgfplots
usepackagepgfplotstable
pgfplotssetcompat=1.16
% from https://tex.stackexchange.com/a/102770/121799
defpgfplotsinvokeiflessthan#1#2#3#4%
pgfkeysvalueof/pgfplots/iflessthan/.@cmd#1#2#3#4pgfeov
%
defpgfplotsmulticmpthree#1#2#3#4#5#6do#7#8%
pgfplotssetfloat <%
pgfplotsinvokeiflessthan#1#4%
% first key <:
#7%
%
pgfplotsinvokeiflessthan#4#1%
% first key >:
#8%
%
% first key ==:
pgfplotssetfloat <%
pgfplotsinvokeiflessthan#2#5%
% second key <
#7%
%
pgfplotsinvokeiflessthan#5#2%
% second key >
#8%
%
% second key ==
pgfplotssetfloat <%
pgfplotsinvokeiflessthan#3#6%
% third key <
#7%
%
% third key >=
#8%
%
%
%
%
%
%
begindocument
ifdefinedgconv
else
pgfmathsetmacrogconv0.1
fi
pgfplotstableread[col sep=comma,header=true]%
y,x,myvalue
1,5,5
2,4,3
3,4,2
4,2,2
5,3,5
6,1,5
7,2,2
8,2,3
9,1,4
1,2,4
1,3,4
2,2,3
2,3,5
2,5,4
3,1,5
3,2,2
3,5,3
4,3,3
4,4,1
4,5,2
5,1,4
5,4,4
5,5,5
6,2,3
6,4,3
6,5,5
7,1,3
7,3,3
7,4,2
8,1,5
8,3,4
8,5,5
9,2,2
9,3,5
9,4,4
10,3,5
10,4,3
10,5,4
datatable
%
%pgfplotstablesort[col sep=comma,header=true]resulttabledatatable
pgfplotstablesort[create on use/sortkey/.style=
create col/assign/.code=%
edefentrythisrowxthisrowythisrowmyvalue%
pgfkeyslet/pgfplots/table/create col/next contententry
,
sort key=sortkey,
sort cmp=%
iflessthan/.code args=#1#2#3#4%
edeftemp#1#2%
expandafterpgfplotsmulticmpthreetempdo#3#4%
,
,
sort,
columns/Mtx/.style=string type,
columns/Kind/.style=string type,]resulttabledatatable
begintikzpicture%[x=(0.866cm,-0.5cm),y=(0.866cm,0.5cm),z=(0cm,1 cm)]
pgfplotssetset layers
beginaxis[% from section 4.6.4 of the pgfplotsmanual
view=12040,
width=320pt,
height=280pt,
z buffer=none,
xmin=-1,xmax=5,
ymin=0,ymax=9,
zmin=0,zmax=10,
enlargelimits=upper,
ztick=0,5,10,
zticklabels=0,2.5,5, % here one has to "cheat"
% meaning that one has to put labels which are the actual value
% divided by 2. This is because the bars will be centered at these
% values
xtick=data,
extra tick style=grid=major,
ytick=data,
grid=minor,
xlabel=$x$,
ylabel=$y$,
zlabel=$z$,
minor tick num=1,
point meta=explicit,
colormap name=viridis,
scatter/use mapped color=
draw=mapped color,fill=mapped color!70,
execute at begin plot=
]
path let p1=($(axis cs:0,0,1)-(axis cs:0,0,0)$) in
pgfextrapgfmathsetmacroconv2*y1
ifxgconvconv
else
xdefgconvconv
typeoutPleasespace recompilespace thespace file!
fi
;
path let p1=($(axis cs:1,0,0)-(axis cs:0,0,0)$) in
pgfextrapgfmathsetmacroconvxveclen(x1,y1)
typeoutOnespace unitspace inspace xspace
directionspace isspaceconvx pt
;
path let p1=($(axis cs:0,1,0)-(axis cs:0,0,0)$) in
pgfextrapgfmathsetmacroconvyveclen(x1,y1)
typeoutOnespace unitspace inspace yspace
directionspace isspaceconvy pt
;
addplot3 [visualization depends on=
gconv*z as myz, % you may have to recompile to get the prefactor right
scatter/@pre marker code/.append style=/pgfplots/cube/size z=myz,%
scatter/@pre marker code/.append style=/pgfplots/cube/size x=11.66135pt,%
scatter/@pre marker code/.append style=/pgfplots/cube/size y=9.10493pt,%
scatter,only marks,
mark=cube*,mark size=5,opacity=1]
table[x expr=thisrowx,y expr=thisrowy,z
expr=1*thisrowmyvalue,
meta expr=-1*thisrowx
] resulttable;
endaxis
makeatletter
immediatewrite@mainauxxdefstringgconvgconvrelax
makeatother
endtikzpicture
enddocument
add a comment |
Here is a proposal. You need to compile twice.
documentclass[tikz,border=3.14pt]standalone
usetikzlibrarycalc
usepackagepgfplots
usepackagepgfplotstable
pgfplotssetcompat=1.16
% from https://tex.stackexchange.com/a/102770/121799
defpgfplotsinvokeiflessthan#1#2#3#4%
pgfkeysvalueof/pgfplots/iflessthan/.@cmd#1#2#3#4pgfeov
%
defpgfplotsmulticmpthree#1#2#3#4#5#6do#7#8%
pgfplotssetfloat <%
pgfplotsinvokeiflessthan#1#4%
% first key <:
#7%
%
pgfplotsinvokeiflessthan#4#1%
% first key >:
#8%
%
% first key ==:
pgfplotssetfloat <%
pgfplotsinvokeiflessthan#2#5%
% second key <
#7%
%
pgfplotsinvokeiflessthan#5#2%
% second key >
#8%
%
% second key ==
pgfplotssetfloat <%
pgfplotsinvokeiflessthan#3#6%
% third key <
#7%
%
% third key >=
#8%
%
%
%
%
%
%
begindocument
ifdefinedgconv
else
pgfmathsetmacrogconv0.1
fi
pgfplotstableread[col sep=comma,header=true]%
y,x,myvalue
1,5,5
2,4,3
3,4,2
4,2,2
5,3,5
6,1,5
7,2,2
8,2,3
9,1,4
1,2,4
1,3,4
2,2,3
2,3,5
2,5,4
3,1,5
3,2,2
3,5,3
4,3,3
4,4,1
4,5,2
5,1,4
5,4,4
5,5,5
6,2,3
6,4,3
6,5,5
7,1,3
7,3,3
7,4,2
8,1,5
8,3,4
8,5,5
9,2,2
9,3,5
9,4,4
10,3,5
10,4,3
10,5,4
datatable
%
%pgfplotstablesort[col sep=comma,header=true]resulttabledatatable
pgfplotstablesort[create on use/sortkey/.style=
create col/assign/.code=%
edefentrythisrowxthisrowythisrowmyvalue%
pgfkeyslet/pgfplots/table/create col/next contententry
,
sort key=sortkey,
sort cmp=%
iflessthan/.code args=#1#2#3#4%
edeftemp#1#2%
expandafterpgfplotsmulticmpthreetempdo#3#4%
,
,
sort,
columns/Mtx/.style=string type,
columns/Kind/.style=string type,]resulttabledatatable
begintikzpicture%[x=(0.866cm,-0.5cm),y=(0.866cm,0.5cm),z=(0cm,1 cm)]
pgfplotssetset layers
beginaxis[% from section 4.6.4 of the pgfplotsmanual
view=12040,
width=320pt,
height=280pt,
z buffer=none,
xmin=-1,xmax=5,
ymin=0,ymax=9,
zmin=0,zmax=10,
enlargelimits=upper,
ztick=0,5,10,
zticklabels=0,2.5,5, % here one has to "cheat"
% meaning that one has to put labels which are the actual value
% divided by 2. This is because the bars will be centered at these
% values
xtick=data,
extra tick style=grid=major,
ytick=data,
grid=minor,
xlabel=$x$,
ylabel=$y$,
zlabel=$z$,
minor tick num=1,
point meta=explicit,
colormap name=viridis,
scatter/use mapped color=
draw=mapped color,fill=mapped color!70,
execute at begin plot=
]
path let p1=($(axis cs:0,0,1)-(axis cs:0,0,0)$) in
pgfextrapgfmathsetmacroconv2*y1
ifxgconvconv
else
xdefgconvconv
typeoutPleasespace recompilespace thespace file!
fi
;
path let p1=($(axis cs:1,0,0)-(axis cs:0,0,0)$) in
pgfextrapgfmathsetmacroconvxveclen(x1,y1)
typeoutOnespace unitspace inspace xspace
directionspace isspaceconvx pt
;
path let p1=($(axis cs:0,1,0)-(axis cs:0,0,0)$) in
pgfextrapgfmathsetmacroconvyveclen(x1,y1)
typeoutOnespace unitspace inspace yspace
directionspace isspaceconvy pt
;
addplot3 [visualization depends on=
gconv*z as myz, % you may have to recompile to get the prefactor right
scatter/@pre marker code/.append style=/pgfplots/cube/size z=myz,%
scatter/@pre marker code/.append style=/pgfplots/cube/size x=11.66135pt,%
scatter/@pre marker code/.append style=/pgfplots/cube/size y=9.10493pt,%
scatter,only marks,
mark=cube*,mark size=5,opacity=1]
table[x expr=thisrowx,y expr=thisrowy,z
expr=1*thisrowmyvalue,
meta expr=-1*thisrowx
] resulttable;
endaxis
makeatletter
immediatewrite@mainauxxdefstringgconvgconvrelax
makeatother
endtikzpicture
enddocument
Here is a proposal. You need to compile twice.
documentclass[tikz,border=3.14pt]standalone
usetikzlibrarycalc
usepackagepgfplots
usepackagepgfplotstable
pgfplotssetcompat=1.16
% from https://tex.stackexchange.com/a/102770/121799
defpgfplotsinvokeiflessthan#1#2#3#4%
pgfkeysvalueof/pgfplots/iflessthan/.@cmd#1#2#3#4pgfeov
%
defpgfplotsmulticmpthree#1#2#3#4#5#6do#7#8%
pgfplotssetfloat <%
pgfplotsinvokeiflessthan#1#4%
% first key <:
#7%
%
pgfplotsinvokeiflessthan#4#1%
% first key >:
#8%
%
% first key ==:
pgfplotssetfloat <%
pgfplotsinvokeiflessthan#2#5%
% second key <
#7%
%
pgfplotsinvokeiflessthan#5#2%
% second key >
#8%
%
% second key ==
pgfplotssetfloat <%
pgfplotsinvokeiflessthan#3#6%
% third key <
#7%
%
% third key >=
#8%
%
%
%
%
%
%
begindocument
ifdefinedgconv
else
pgfmathsetmacrogconv0.1
fi
pgfplotstableread[col sep=comma,header=true]%
y,x,myvalue
1,5,5
2,4,3
3,4,2
4,2,2
5,3,5
6,1,5
7,2,2
8,2,3
9,1,4
1,2,4
1,3,4
2,2,3
2,3,5
2,5,4
3,1,5
3,2,2
3,5,3
4,3,3
4,4,1
4,5,2
5,1,4
5,4,4
5,5,5
6,2,3
6,4,3
6,5,5
7,1,3
7,3,3
7,4,2
8,1,5
8,3,4
8,5,5
9,2,2
9,3,5
9,4,4
10,3,5
10,4,3
10,5,4
datatable
%
%pgfplotstablesort[col sep=comma,header=true]resulttabledatatable
pgfplotstablesort[create on use/sortkey/.style=
create col/assign/.code=%
edefentrythisrowxthisrowythisrowmyvalue%
pgfkeyslet/pgfplots/table/create col/next contententry
,
sort key=sortkey,
sort cmp=%
iflessthan/.code args=#1#2#3#4%
edeftemp#1#2%
expandafterpgfplotsmulticmpthreetempdo#3#4%
,
,
sort,
columns/Mtx/.style=string type,
columns/Kind/.style=string type,]resulttabledatatable
begintikzpicture%[x=(0.866cm,-0.5cm),y=(0.866cm,0.5cm),z=(0cm,1 cm)]
pgfplotssetset layers
beginaxis[% from section 4.6.4 of the pgfplotsmanual
view=12040,
width=320pt,
height=280pt,
z buffer=none,
xmin=-1,xmax=5,
ymin=0,ymax=9,
zmin=0,zmax=10,
enlargelimits=upper,
ztick=0,5,10,
zticklabels=0,2.5,5, % here one has to "cheat"
% meaning that one has to put labels which are the actual value
% divided by 2. This is because the bars will be centered at these
% values
xtick=data,
extra tick style=grid=major,
ytick=data,
grid=minor,
xlabel=$x$,
ylabel=$y$,
zlabel=$z$,
minor tick num=1,
point meta=explicit,
colormap name=viridis,
scatter/use mapped color=
draw=mapped color,fill=mapped color!70,
execute at begin plot=
]
path let p1=($(axis cs:0,0,1)-(axis cs:0,0,0)$) in
pgfextrapgfmathsetmacroconv2*y1
ifxgconvconv
else
xdefgconvconv
typeoutPleasespace recompilespace thespace file!
fi
;
path let p1=($(axis cs:1,0,0)-(axis cs:0,0,0)$) in
pgfextrapgfmathsetmacroconvxveclen(x1,y1)
typeoutOnespace unitspace inspace xspace
directionspace isspaceconvx pt
;
path let p1=($(axis cs:0,1,0)-(axis cs:0,0,0)$) in
pgfextrapgfmathsetmacroconvyveclen(x1,y1)
typeoutOnespace unitspace inspace yspace
directionspace isspaceconvy pt
;
addplot3 [visualization depends on=
gconv*z as myz, % you may have to recompile to get the prefactor right
scatter/@pre marker code/.append style=/pgfplots/cube/size z=myz,%
scatter/@pre marker code/.append style=/pgfplots/cube/size x=11.66135pt,%
scatter/@pre marker code/.append style=/pgfplots/cube/size y=9.10493pt,%
scatter,only marks,
mark=cube*,mark size=5,opacity=1]
table[x expr=thisrowx,y expr=thisrowy,z
expr=1*thisrowmyvalue,
meta expr=-1*thisrowx
] resulttable;
endaxis
makeatletter
immediatewrite@mainauxxdefstringgconvgconvrelax
makeatother
endtikzpicture
enddocument
answered 2 hours ago
marmotmarmot
128k6162308
128k6162308
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f491565%2f3d-histogram-bar-chart%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Yes, it is, see here. Do you have the data in another form than a screen shot but just text?
– marmot
2 hours ago
Yes, I do! I will edit the post with the text data.
– naveganteX
2 hours ago