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
What could a self-sustaining lunar colony slowly lose that would ultimately prove fatal?
Is it legal to have an abortion in another state or abroad?
Specific alignment within beginalign environment
How to draw Sankey diagram with Tikz?
Which European Languages are not Indo-European?
Why did Jon Snow do this immoral act if he is so honorable?
How to cut a climbing rope?
Looking for a soft substance that doesn't dissolve underwater
What is the function of the corrugations on a section of the Space Shuttle's external tank?
Can a British citizen living in France vote in both France and Britain in the European Elections?
Can my floppy disk still work without a shutter spring?
Is the Unsullied name meant to be ironic? How did it come to be?
Why are GND pads often only connected by four traces?
Should one buy new hardware after a system compromise?
Why does Mjolnir fall down in Age of Ultron but not in Endgame?
Did this character show any indication of wanting to rule before S8E6?
Do photons bend spacetime or not?
NIntegrate doesn't evaluate
Popcorn is the only acceptable snack to consume while watching a movie
Did 20% of US soldiers in Vietnam use heroin, 95% of whom quit afterwards?
Need to understand my home electrical meter to see why bill is so high and/or if neighbor is on same meter
Is it truly impossible to tell what a CPU is doing?
Why did Theresa May offer a vote on a second Brexit referendum?
Can the product of any two aperiodic functions which are defined on the entire number line be periodic?
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
May 19 at 3:24
Yes, I do! I will edit the post with the text data.
– naveganteX
May 19 at 3:26
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 May 19 at 3:49
naveganteX
asked May 19 at 3:22
naveganteXnaveganteX
3618
3618
Yes, it is, see here. Do you have the data in another form than a screen shot but just text?
– marmot
May 19 at 3:24
Yes, I do! I will edit the post with the text data.
– naveganteX
May 19 at 3:26
add a comment |
Yes, it is, see here. Do you have the data in another form than a screen shot but just text?
– marmot
May 19 at 3:24
Yes, I do! I will edit the post with the text data.
– naveganteX
May 19 at 3:26
Yes, it is, see here. Do you have the data in another form than a screen shot but just text?
– marmot
May 19 at 3:24
Yes, it is, see here. Do you have the data in another form than a screen shot but just text?
– marmot
May 19 at 3:24
Yes, I do! I will edit the post with the text data.
– naveganteX
May 19 at 3:26
Yes, I do! I will edit the post with the text data.
– naveganteX
May 19 at 3:26
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 May 19 at 3:48
marmotmarmot
129k6163311
129k6163311
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
May 19 at 3:24
Yes, I do! I will edit the post with the text data.
– naveganteX
May 19 at 3:26